Building Agents with the Swiss AI Hub SDK
An agent in the Swiss AI Hub is a workflow defined by a series of steps that process events. Agents can interact with users, call external services, and coordinate with other agents to perform complex tasks.
This documentation guides you through the architecture, patterns, and best practices for building robust and scalable agents.
WARNING
Before you begin, please complete the Development Environment Setup and build Your First Agent.
What's Covered
This guide is structured to build your knowledge progressively:
- Agent Fundamentals - The core architecture, including events, steps, and configuration.
- Core Patterns - Essential workflow patterns like conditional logic, loops, and state management.
- Human in the Loop - Building interactive workflows that require human approval or input.
- Multi-Agent Systems - Coordinating multiple agents to solve complex problems.
- Memory - Adding persistent memory to your agents for user preferences and organizational knowledge.
- Testing and Debugging - Best practices for ensuring your agent is reliable and correct.
- Production Deployment - Guidelines for packaging and deploying your agent.
- Agent Observation - Monitoring your agent's behavior and performance with integrated tracing.
- Configurable Agent Forms - Making agent configuration editable through the Admin UI using the Form Duality Pattern.
- Execution Model - How the dispatcher executes steps, synchronization primitives, anti-patterns, and troubleshooting.
- Events Reference - Complete event hierarchy, choosing the right base event, and available events catalog.
- Using MCP Tools - Connecting agents to external MCP servers to call their tools.
Key Principles of the SDK
The SDK is designed around a few core principles to make development intuitive and scalable:
- Event-Driven by Nature: Agents react to a stream of events. This asynchronous, message-based architecture makes workflows dynamic and resilient.
- Declarative Workflows: You define what each step does using the
@stepdecorator. The SDK automatically handles the how of routing events and wiring your steps together. - Managed State: Handle conversation memory and run-time data effortlessly with injectable
RunContextandThreadContextobjects, backed by a distributed store. - Built for Production: With strongly-typed configuration, a dedicated testing framework, and built-in observability.
The Development Workflow
Building a high-quality agent typically follows these four stages:
TIP
A core design principle is that each agent should do one thing well. Complex problems are best solved by coordinating multiple specialized agents.
- Design Your Workflow: Outline your agent's purpose, the events it will handle, and the sequence of steps it will take to achieve its goal.
- Implement the Core Logic: Write your
Agentclass, define its strongly-typedAgentConfig, and implement the@stepmethods that transform events. - Test and Debug: Use the
AgentTestRunnerfor unit testing and a tracing tool like Langfuse to visually debug the flow of events through your agent. - Deploy and Monitor: Package your agent and deploy it to the Swiss AI Hub, where its performance and behavior can be monitored in real-time.
Next Steps
Start with agent fundamentals to understand the core architecture, then explore the specific patterns and techniques in the following sections.
