Building AI Agents in Rust — part 3
Author(s): Enzo Lombardi Originally published on Towards AI. Skills as traits Two tools fit in a match statement. Three start to feel cramped. By six, the dispatcher is a swamp of clones, retries, error formatting, and case branches that all look almost but not quite alike. The agent loop is still simple. The space around it is not. The article proposes replacing the brittle match-based dispatcher with a typed trait approach: define each “skill” as its own trait implementation with associated input types, runtime metadata (read-only vs destructive and concurrency safety), and standardized error handling so the system can reason about failures. It introduces a registry to own dispatch, generate JSON Schema from Rust structs (so model and code stay in sync), and run multiple tool calls in parallel when safe. Beyond dispatch, it covers resilience via retry helpers for transient errors, cross-cutting behavior via pre/post “hooks” (permissions, logging, redaction, caching), and scaling strategies (deferring large tool sets using search hints, aliases, and on-demand loading). Finally, it distills three rules—atomic skills, result-based outputs, and safety-first input handling—and shows how the pattern fits Eugene v0.3 in practice. Read the full blog for free on Medium. Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor. Published via Towards AI
