Skip to content

[Bug]: inputs in .addSkill are not recognized by the agent #255

@moinism

Description

@moinism

🐛 What happened?

The agent does not know which inputs are required for a skill if they are passed as inputs to the skill constructor. It always passes an 'input', ignoring the defined ones.

I think this is the culprit, _in is being set to an empty object instead of the constructor argument inputs:

const _in: { [key: string]: ComponentInput } = {};

The inputs are recognized only if skill.in() method is used, but it still passes an extran input named input of string type for some reason.

🔄 How to reproduce

import { Agent, Model } from "@smythos/sdk"
const agent = new Agent({
  name: "Research Helper",
  behavior:
    "You are a research helper. Use the Web Search skill to get information for any question before answering.",
  model: Model.Groq("openai/gpt-oss-20b"),
})

agent.addSkill({
  name: "Web Search",
  description: "Search the web for information",
  inputs: {
    searchQuery: {
      type: "Text",
      description: "The query to search the web for",
    },
  },
  process: async (input) => {
    const { searchQuery } = input
    console.log(`Searching the web for ${searchQuery}`, input)
    return `Search results for ${searchQuery}: Paris`
  },
})

const chat = agent.chat()
const result = await chat.prompt("What is the capital of France?")
console.log(result)

Running the above code will result in something like:

Searching the web for undefined { input: 'capital of France' }
Searching the web for undefined { input: 'capital of France' }
...

Now update the above code with:

const skill = agent.addSkill({
  name: "Web Search",
  description: "Search the web for information",
  inputs: {
    searchQuery: {
      type: "Text",
      description: "The query to search the web for",
    },
  },
  process: async (input) => {
    const { searchQuery } = input
    console.log(`Searching the web for ${searchQuery}`, input)
    return `Search results for ${searchQuery}: Paris`
  },
})

skill.in({
  searchQuery: {
    type: "Text",
    description: "The query to search the web for",
  },
})

Now the output would be something like:

Searching the web for capital of France { input: 'capital of France', searchQuery: 'capital of France' }

💻 Code sample

🖥️ Environment

Package: @smythos/sdk 1.3.12

✅ Checklist

  • Searched existing issues
  • Provided reproduction steps

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions