Core Concepts
Learn about the fundamental concepts of the Agentuity Python SDK
The Agentuity Python SDK is built around several key concepts that form the foundation of agent development. Understanding these concepts is essential for effectively using the SDK.
Agent Architecture
Agents in the Agentuity SDK are modular components that can process requests and generate responses. Each agent:
- Has a unique identifier and name
- Can be triggered by various events (webhooks, cron jobs, manual invocation, etc.)
- Processes requests through a handler function
- Has access to a context object with various capabilities
The basic structure of an agent looks like this:
Configuration
Agent configuration (name, description, etc.) is managed by the Agentuity CLI and stored in the project configuration file.
Use the agentuity project
and agentuity agent
commands to manage your configuration.
Request and Response Handling
The Agentuity SDK provides a structured way to handle requests and generate responses:
Requests
Requests contain information about the trigger event and payload data. The AgentRequest
interface provides methods to access this data in various formats:
request.trigger
- Get the trigger type (webhook, manual,cron, etc.)request.metadata
- Access metadata associated with the requestrequest.get(key, defval)
- Get a value from the request metadatarequest.data
- Get a Data object from the requestrequest.data.contentType
- The content type (or mime type) of the requestrequest.data.text
- Get the payload as a stringrequest.data.json
- Get the payload as a JSON objectrequest.data.binary
- Get the payload as a binary objectrequest.data.base64
- Get the payload as a base64 encoded string
Responses
Responses are created using the AgentResponse
interface, which provides methods for different response types:
response.json()
- Return a JSON responseresponse.text()
- Return a text responseresponse.binary()
- Return a binary responseresponse.html()
- Return an HTML responseresponse.empty()
- Return an empty response- Various media-specific methods (pdf(), png(), jpeg(), etc.)
response.handoff()
- Redirect to another agent
Agent Context
The context object provides access to various capabilities and services:
context.logger
- Logging functionalitycontext.kv
- Key-value storagecontext.vector
- Vector storagecontext.get_agent()
- Access to other agents both locally and remotelycontext.tracer
- OpenTelemetry tracing- Metadata about the current execution (runId, projectId, etc.)
Triggers and Event Types
Agents can be triggered by various event types:
webhook
- HTTP webhook callscron
- Scheduled cron jobsmanual
- Manual invocationagent
- Calls from other agentssms
- SMS messagesqueue
- Queue processingvoice
- Voice callsemail
- Email messages
Each trigger type may provide different metadata and payload formats, which can be accessed through the request object.