This is detailed usage documentation. New to Agentica? Start with the Quickstart or learn when to use agents vs magic functions.
Using agents
Agents in Agentica accomplish specific tasks using native libraries, code, APIs, and SDKs available in your programming language’s runtime. A single agent represents an evolving history of invocations, each of which may be provided a specific task and set of resources.When to use agents
Agents work best for longer-running, multi-step tasks where each action depends on prior outcomes, state is preserved, and task-appropriate sets of resources need to be delegated. For single, well-bounded tasks without cross-step context, see Magic functions.The basics
Agents can be created in Agentica usingspawn and later called to perform tasks. An agent’s history evolves across its invocations, so you can follow up with tasks in the context of previous results.
In Python, provide a return type to receive a result of that runtime type (defaulting to str). In TypeScript, the return type is inferred from the prompt and response.
Use your tools and types
Any function, object, method, or other runtime value can be directly exposed as resources your agent can interact with. No need to set up MCP servers. Expose the full programmatic power of an SDK or API directly to your agent. Make them available when spawning the agent and/or pass per-invocation resources. You can also expose existing remote or local MCP tools by passing an MCP configuration path. See Advanced › MCP.Multi-agent orchestration
Multi-agent orchestration becomes straightforward. Agents can trigger sub-agents by passingspawn in scope, enabling completely dynamic agent delegation.
Streaming
Stream responses as they are being generated.Example logs
Example logs