Skip to content

Tool Calling Agent

The Tool Calling Agent lets you create an AI assistant that can use external tools to answer user questions. It takes a language model, a set of tools, and a prompt, and returns a response that may include calls to those tools.

⚠️ DEPRECATION WARNING

This component is deprecated and will be removed in a future version of Nappai. Please migrate to the recommended alternative components.

How it Works

The component builds an AgentExecutor from LangChain.
It takes the language model you provide, the tools you want the agent to use, and a prompt that tells the agent what to do.
When you run the agent, it will:

  1. Read the system prompt (e.g., “You are a helpful assistant”).
  2. Look at the user prompt you supplied (which must contain an input key).
  3. Use the chat history to keep context.
  4. Ask the language model to decide whether it can answer the question directly or if it needs to call one of the tools.
  5. If a tool is needed, it calls that tool (for example, GetCurrentDatetime) and feeds the result back to the model.
  6. The process repeats until the model decides it has a final answer or the maximum number of iterations is reached.

The component also lets you turn off streaming, choose an early‑stopping method, and control how many times the agent can loop.

Inputs

  • Chat History – The conversation that has already happened. The agent uses this to keep context.
  • Model – The language model that will generate text and decide when to call tools. This input is required.
  • Tools – A list of tools the agent can use. Each tool can perform a specific task, like getting the current date.
  • Disable Streaming – If checked, the model will not stream its output. This can make the response appear faster but you won’t see it in real time.
  • Early Stopping Method – Lets you stop the agent early if it keeps looping. Options are “None”, “generate”, or “force”.
  • Executor Name – A name you give to the agent’s execution run. It’s used for logging and debugging.
  • Handle Parse Errors – If the agent can’t parse a tool call, this flag tells it whether to try again or fail.
  • Input – The raw user input that will be inserted into the prompt.
  • Max Iterations – The maximum number of times the agent can loop before giving up.
  • System Prompt – A short instruction that sets the agent’s overall behavior (e.g., “You are a helpful assistant”).
  • Prompt – The template that the agent uses to ask the user’s question. It must contain the key input.
  • Verbose – If enabled, the agent will log detailed information about its internal steps.

Outputs

  • Agent – The built AgentExecutor object. You can use this to run the agent in other parts of your workflow.
  • Response – The final message produced by the agent. It can be plain text or a tool call result.

Usage Example

  1. Add the Tool Calling Agent to your dashboard.
  2. Connect a language model (e.g., OpenAI GPT‑4) to the Model input.
  3. Add the GetCurrentDatetime tool to the Tools input.
  4. Set the System Prompt to “You are a helpful assistant.”
  5. Set the Prompt to “What is the current date and time? {input}”.
  6. Leave Disable Streaming unchecked and Max Iterations at the default.
  7. Click Run.
  8. The agent will read the user’s question, call GetCurrentDatetime, and return the current date and time.
  • Base Agent – The foundational agent component that this one builds upon.
  • Tool – A reusable piece of functionality that the agent can call.
  • Chat History – Stores past messages so the agent can maintain context.

Tips and Best Practices

  • Keep the Prompt simple and always include the input key.
  • Use Early Stopping Method if you notice the agent looping too long.
  • Turn off Streaming when you need a quick, single‑shot response.
  • Add only the tools you really need; each tool adds a bit of overhead.
  • Test the agent with a few sample inputs before deploying it in production.

Security Considerations

  • The component sets allow_dangerous_code to True, meaning the agent can execute code that might be risky.
  • Only provide tools that you trust and that have been reviewed for security.
  • Avoid exposing sensitive data in the Prompt or System Prompt.
  • Monitor the agent’s logs if you enable Verbose to catch unexpected behavior early.