Skip to main content
xpander provides a unified API across all agent frameworks. No matter which framework you use, you get a standardized way to:
  • Schedule and list tasks - consistent task management
  • Consume tools - from the catalog or custom
  • Manage prompts - version-controlled system prompts
  • Handle memory - PostgreSQL-backed state
  • Deploy containers - K8s (cloud or self-hosted)
How it works:
  1. Create an agent (via Workbench, SDK, or API)
  2. Use Backend().aget_args() to get framework-specific config
  3. Initialize your framework with the returned args
  4. Use @on_task to handle incoming tasks
By using @on_task, your agent automatically supports:
  • Multiple interfaces - Slack, Web UI, API, Agent-to-Agent (A2A)
  • Retry mechanism - automatic retries on failure
  • Auto-scaling - if unavailable, xpander schedules a new instance
  • Observability - built-in logging and monitoring

Framework Examples

What’s in backend.aget_args()? The Backend returns framework-specific arguments including:
PropertyDescription
modelConfigured AI model instance
instructionsSystem prompt from Workbench
descriptionAgent description
toolsTools from the catalog + custom @register_tool
dbPostgreSQL connection for memory
session_idTask ID for conversation tracking
  • Agno
  • Strands (AWS)
  • Google ADK
  • OpenAI Agents SDK
  • LangChain
from xpander_sdk import Task, on_task, Backend, Configuration
from agno.agent import Agent

@on_task(
    Configuration(
        api_key="{XPANDER_API_KEY}",
        organization_id="{XPANDER_ORGANIZATION_ID}",
        agent_id="{XPANDER_AGENT_ID}"
    )
)
async def my_agent_handler(task: Task):
    # Initialize Agno with xpander's configuration
    backend = Backend(configuration=task.configuration)
    agno_agent = Agent(**await backend.aget_args(task=task))

    # Run the agent
    result = await agno_agent.arun(
        input=task.to_message(),
        files=task.get_files(),
        images=task.get_images()
    )
    task.result = result.content

    return task

Local Development

Option 1: CLI

# Install the xpander CLI
npm install -g xpander-cli

# Run agent locally - connects to xpander platform for tools, prompts, and task handling
xpander agent dev [agent-name]
Once running, your agent is available via:
  • Web UI - https://<agent-name>.agents.xpander.ai
  • API - curl -X POST https://api.xpander.ai/v1/agents/<agent-id>/invoke -H 'x-api-key: <key>' -d '{"input":{"text":"hi!"}}'
  • SDK - Tasks().create(agent_id="...", input=...)
  • CLI - xpander agent invoke [agent-name] "test message"
See Invoke API for more options.

Option 2: Inline test task

Run your code directly with a test task - no CLI needed:
from xpander_sdk import on_task, Configuration
from xpander_sdk.modules.tasks.models.task import AgentExecutionInput, LocalTaskTest

test_task = LocalTaskTest(
    input=AgentExecutionInput(text="Your test input here"),
)

@on_task(
    Configuration(
        api_key="{XPANDER_API_KEY}",
        organization_id="{XPANDER_ORGANIZATION_ID}",
        agent_id="{XPANDER_AGENT_ID}"
    ),
    test_task=test_task  # Runs immediately with this test input
)
async def my_agent_handler(task):
    # Your agent logic here
    ...
Starting from scratch? Use xpander agent init [agent-name] to scaffold a new project with Dockerfile, requirements.txt, and xpander_handler.py.

Deployment

Deploy your container to xpander’s infrastructure:
Deployment
# Deploy to xpander cloud
xpander deploy

# View logs
xpander agent logs [agent]

# Restart container
xpander agent restart [agent]
For self-hosted deployment on your own Kubernetes cluster, see the Self-Hosted Deployment Guide.

Next Steps