Features
On this page, we explain the features of the Workflow Agents API in more detail.
Prerequisites:
- Setup your first Agent endpoint by following the Getting Started page.
- Install the following packages to define tools:
Models
Currently, OpenAI is the only supported provider for agents, but more providers will be available in the future. If you have a specific provider request, feel free to reach out.
First, add QSTASH_TOKEN
and OPENAI_API_KEY
to your environment:
Next, define the model in your route:
The model
is responsible for deciding which tools to call and generating the final response, as we will explore in the following sections.
Tools
Next, we will define the tools that our agents will use. The Agents API is compatible with both AI SDK and LangChain tools. This means you can either:
- Use existing tools that are compatible with these SDKs.
- Define your own custom tools that are compatible with these SDKs.
This flexibility allows you to tailor the tools to your specific needs while leveraging the power of these frameworks.
For available toolkits, you can explore the LangChain Toolkits or other AI SDK-compatible toolkits like Agentic.
Agents
After defining a model and tools, we can define agents. Agents are essentially LLM models with access to a set of tools and background knowledge. In Upstash Workflow, agents are defined like this:
The parameters for defining an agent are as follows:
model
: The LLM model that the agent will use.name
: The name of the agent. This name will be used when naming the context.call steps for this agent.context.call
is used when calling the LLM provider (such as OpenAI).maxSteps
: The maximum number of times this agent can call the LLM provider (e.g., OpenAI).tools
: The list of tools available to the agent for completing tasks.background
: A description of the agent, which is used as a system prompt to provide context for the agent’s behavior.
Tasks
Now that we have agents defined, the only thing left is to assign tasks to them. A task is simply a prompt passed to the agent.
There are two ways to create a task:
-
Single Agent Task: The task is assigned to a single agent, which will complete it using the tools available to it.
-
Multiple Agent Task: A manager agent is used to decide which agents will be involved and in what order. The manager agent makes this decision based on the task prompt, the agents’ backgrounds, and the tools available to them.
Single Agent
As response to the task, the agent generates the following response:
Here is the logs on Upstash Console:
In the logs, you can see that the academic agent was called. It decided to invoke wikiTool five times in parallel. Once the tool requests were completed, the agent summarized the results from the individual calls in one final response and returned the outcome.
Multi Agents
As response to the task, the agents generate the following response:
Here are the logs on Upstash Console:
The logs show that the Manager LLM
first called the academic
agent. The academic
agent used the wikiTool
three times, each with a different Japanese city, and summarized the results. Next, the Manager LLM
called the mathematician
agent, which used its calculate
tool to compute the total population of the three cities and returned the result to the Manager LLM
. With information about the cities and their total population, the Manager LLM
generated the final response.
Was this page helpful?