Class Definition
Unlike other context classes,
AgentContext is not abstract and provides a default execute() implementation that runs the agent loop.Type Parameters
| Parameter | Description |
|---|---|
InSchema | Input schema type |
OutSchema | Output schema type |
In | Inferred input type |
Out | Inferred output type |
Properties
| Property | Type | Description |
|---|---|---|
metadata | AgentMetadata | Agent metadata |
input | In | Agent input |
output | Out | undefined | Agent output |
llmAdapter | AgentLlmAdapter | LLM provider adapter |
systemInstructions | string | System prompt |
toolDefinitions | AgentToolDefinition[] | Available tools |
agentName | string | Agent name |
agentId | string | Agent ID |
platform | AIPlatformType | Detected AI platform |
clientInfo | ClientInfo | undefined | Client information |
Default Behavior
By default, agents run an automatic execution loop:- Builds user message from input
- Sends to LLM with available tools
- If LLM requests tool call, executes tool and sends result back
- Repeats until LLM returns final response
- Parses and returns output
Methods
Execution
execute(input)
Main execution method. Override for custom behavior.runAgentLoop().
runAgentLoop(input)
Run the default agent execution loop.Message Building (Overridable)
buildUserMessage(input)
Convert input to LLM message.parseAgentResponse(content)
Parse LLM response to output type.LLM Methods
completion(prompt, tools?, options?)
Generate LLM completion.streamCompletion(prompt, tools?)
Stream LLM completion.Tool Execution
executeTool(name, args)
Execute a tool by name.invokeAgent(agentId, input)
Invoke another agent.Notifications
notify(message, level?)
Send log message notification.progress(progress, total?, message?)
Send progress notification.Elicitation
elicit<S>(message, requestedSchema, options?)
Request interactive user input.Custom Agent Example
Multi-Agent Orchestration
Full Example
Related
@Agent
Agent decorator
AgentRegistry
Agent registry
Agent Errors
Agent errors
@Tool
Tool decorator