Skip to main content

Virtual Environment Setup

setup.sh
python3 -m venv .venv
source .venv/bin/activate
pip install "xpander-sdk[agno]"

Environment Setup

The .env file is created when you download your agent code:
xpander init
This downloads your agent code from the platform with the .env file pre-configured with your keys.
async_task_example.py
from dotenv import load_dotenv
load_dotenv()

from xpander_sdk import Task, Backend, on_task
from agno.agent import Agent

@on_task
async def task_handler(task: Task):
    backend = Backend()
    agno_args = await backend.aget_args(task=task)
    agno_agent = Agent(**agno_args)
    
    # Get files and images for comprehensive processing
    files = task.get_files()    # PDF files as Agno File objects
    images = task.get_images()  # Image files as Agno Image objects
    
    # Process task asynchronously with file support
    result = await agno_agent.arun(
        input=task.to_message(),  # Includes text + file content
        files=files,              # PDF files
        images=images            # Image files
    )
    task.result = result.content
    return task
This example shows non-blocking task processing where multiple tasks can be handled concurrently without blocking other operations. It uses asynchronous backend initialization with aget_args() for optimal resource utilization, automatic file categorization and handling for Agno integration, and task-to-message conversion with proper result handling.

Production Deployment

For creating and deploying agents to production, see the Setup and Deployment Guide.
I