Agents
The core building block — name, instructions, model, tools, and memory.
An Agent is the main building block of ABZ Agent SDK. It processes user input, follows the instructions you give it, and generates a response using the model you choose.
Creating one takes only a few lines of code.
Create an Agent#
agent.py
from abzagent import Agent
agent = Agent(
name="ABZ Assistant",
instructions="You are a helpful AI assistant.",
model="gemini-2.5-flash"
)Run an Agent#
Use the run() method to send a prompt to your agent.
Python
result = agent.run("Explain what an AI agent is.")
print(result.content)The model's response is available through result.content.
How It Works#
- Your
instructionsare sent to the model as its system prompt, shaping how it behaves for every request. run()sends your prompt to the model configured inmodeland waits for a response.- If the agent has
tools, the model can call them before producing a final answer. - The result is wrapped in a response object —
result.contentfor text, orresult.parsedwhen using Structured Output.
Agent Parameters#
When creating an agent, you can configure the following options.
| Parameter | Description |
|---|---|
name | Name of the agent. |
instructions | Defines how the agent should behave. |
model | The AI model used by the agent. |
tools | Register function tools or built-in tools. |
memory | Enable conversation memory. |
output_type | Return a validated Pydantic object instead of raw text. |
input_guardrails | Validate user input before it reaches the model. |
output_guardrails | Validate the model's response before it's returned. |
handoffs | Let this agent transfer the conversation to a specialist agent. |
Extending an Agent#
Every capability below is optional — add what your application needs, when it needs it.
- Memory — remember previous turns in the conversation.
- Function Tools — let the agent call your own Python functions.
- Built-in Tools — ready-to-use tools included with the SDK.
- Structured Output — return validated Python objects instead of text.
- Guardrails — control what the agent accepts and returns.
- Handoffs — transfer a conversation to a specialist agent.
Example#
math_assistant.py
from abzagent import Agent
agent = Agent(
name="Math Assistant",
instructions="Answer math questions clearly.",
model="gemini-2.5-flash"
)
result = agent.run("What is 15 × 12?")
print(result.content)Next Step#
Continue to Memory to learn how your agent can remember previous conversations.