- direct instantiation via
Agent.__init__ - awaitable instantiation via the
spawnfunction Both return an instance of theAgentclass.
spawn
An optional premise for the agent. This will be attached to the system prompt of all invocations of this agent.
An optional default set of resources which the agent will have access to indefinitely.
Resources in scope may be arbitrary Python functions, methods, objects, iterators, types or any other Python value.
These resources may additionally be specified per invocation later on.
An optional system prompt for the agent. This will be the system prompt of all invocations of this agent.
The string of a path to a
.json file representing an MCP configuration. Any servers and/or tools of servers outlined in the config can be used during the agent’s run.The model which backs your agent.One of:
openai:gpt-3.5-turboopenai:gpt-4oopenai:gpt-4.1openai:gpt-5anthropic:claude-sonnet-4anthropic:claude-opus-4.1anthropic:claude-sonnet-4.5
openai:gpt-4.1.The maximum number of tokens that the agent can generate during one round of inference.Defaults to
2048.An optional listener for logging the agent’s activity and chat history.
If the global default listener is enabled, and this is set to None, the default listener will be used.
Agent
The Agent class represents a stateful agent that maintains conversation history.__init__
agentica.spawn(...) for a description of Agent.__init__ arguments.
call
Invoke the agent with a task.
Provide a return type for the agent to have it return an instance of a specific type
T.- Providing a return type is optional; *if you do not provide a
return_type, thereturn_typewill default tostr. - You may specify a return type of
Noneif you do not care about the result, only the side effects.
The agent’s task (or objective) for this invocation of the agent.
If the
system argument is provided when spawning the agent, task will be provided as a raw user prompt.The string of a path to a
.json file representing an MCP configuration. Any servers and/or tools of servers outlined in the config can be used during the agent’s run.Any additional resources added to the agent’s scope for this invocation.
The result the agent returns must be awaited.