createAgent
Define an agent
Agents are defined using the createAgent
function.
Options
The name of the agent. Displayed in tracing.
Optional description for the agent, used for LLM-based routing to help the network pick which agent to run next.
The provider model to use for inference calls.
The system prompt, as a string or function. Functions let you change prompts based off of state and memory
Defined tools that an agent can call.
Tools are created via createTypedTool
.
Lifecycle hooks that can intercept and modify inputs and outputs throughout the stages of execution of run()
.
Learn about each lifecycle hook that can be defined below.
lifecycle
Called after the initial prompt messages are created and before the inference call request. The onStart
hook can be used to:
- Modify input prompt for the Agent.
- Prevent the agent from being called by throwing an error.
Called after the inference call request is completed and before tool calling. The onResponse
hook can be used to:
- Inspect the tools that the model decided to call.
- Modify the response prior to tool calling.
Called after tool calling has completed. The onFinish
hook can be used to:
- Modify the
InferenceResult
including the outputs prior to the result being added to Network state.