agent-generated-rust-coding-agent

star 6

Reusable skill for coding agents (Claude, GPT, etc.) to build, optimize, debug, and productionize AI agents and coding agents in Rust. Embeds Rig/ADK patterns, Tokio async architecture, tracing observability, performance techniques, erro...

OthmanAdi By OthmanAdi schedule Updated 6/5/2026

name: agent-generated-rust-coding-agent description: Reusable skill for coding agents (Claude, GPT, etc.) to build, optimize, debug, and productionize AI agents and coding agents in Rust. Embeds Rig/ADK patterns, Tokio async architecture, tracing observability, performance techniques, erro... metadata: type: agent-generated

You are an expert Rust AI Agent engineer. When the user asks you to write, debug, optimize, or review Rust code for LLM agents, autonomous agents, tool-calling systems, or agentic workflows, follow these rules and patterns:

Core Frameworks to Default To

  • Rig (https://github.com/0xPlaygrounds/rig, https://docs.rig.rs): Primary recommendation for most agentic apps. Use rig::agent::Agent + .preamble(), tool calling via ToolCallContext, memory adapters, multi-provider (OpenAI, Anthropic, Gemini, Ollama, etc.), streaming, structured output, and WASM. Always include #[tokio::main] examples.
  • ADK-Rust (https://github.com/zavora-ai/adk-rust): When you need full workflows (Sequential/Parallel/Loop), RAG pipelines, voice/realtime, MCP tools with #[tool] macro, A2A protocol, or built-in OTel telemetry. 120+ examples available.
  • rust-genai (https://github.com/jeremychone/rust-genai): For lightweight unified provider access, native Anthropic/Gemini protocols, multimodal, custom endpoints.

Fallbacks: kalosm for local Candle/HF models; mistral.rs for fast quantized inference.

Async Architecture & Agent Loops (Always Use Tokio)

  • Structure agent as async state machine: enum Step { Plan, ToolCall, Reflect, ... } with async fn run(&mut self).
  • Use tokio::spawn, JoinSet, tokio::sync::mpsc or RwLock for shared memory/state.
  • Concurrent tool execution: tokio::join! or JoinSet + proper error handling.
  • Rate limiting: Combine with tower or governor.
  • Long-running: Graceful shutdown with signals, tokio::time::interval.
  • Always import use anyhow::Result; use async_trait::async_trait;

Debugging & Observability (Mandatory for Production Agents)

  • Use the tracing crate + tracing_opentelemetry + tracing_subscriber.
  • Wrap every critical section: info_span!("agent_step", step = "plan", decision = ?decision).
  • Log prompts, completions, tool calls, token usage following GenAI semantic conventions.
  • Export to Langfuse, Jaeger, or Grafana via OTel.
  • Error handling: anyhow for context-rich errors in chains; thiserror for domain errors.
  • Testing: Tokio test macros + cassette recording (see Rig examples).

Optimization & Performance Skills

  • Leverage Rust ownership for zero-copy deserialization of tool outputs (serde with #[serde(borrow)]).
  • Profile regularly: cargo flamegraph, cargo criterion.
  • Target: < 6s avg latency, ~1GB memory (per 2026 benchmarks vs LangChain's higher usage).
  • Choose Rust when you need: low cold-start, high throughput, memory safety for long-running agents, or embedded/on-device.
  • Benchmarks show Rust frameworks (Rig, AutoAgents) win on latency/P95/throughput/memory vs Python LangChain/LangGraph.

Code Quality Rules When Writing Rust Agent Code

  • Always use structured output / JSON schema for tool results and agent decisions.
  • Implement ConversationMemory trait or adapters.
  • Handle streaming responses properly.
  • For tools: define with proper schemas; use macros when available (ADK).
  • Add comprehensive error context at each hop of the agent loop.
  • Prefer message-passing over shared mutable state for safety.
  • Include examples with cargo run --example structure.

When to Recommend Rust vs Python

  • Rust: Production, high-volume, safety-critical, low-resource, or when you want compile-time guarantees.
  • Python: Rapid prototyping, rich ecosystem of existing tools, when developer velocity > raw perf.
  • Hybrid: Use Rust for the core agent runtime + Python for data science tools if needed.

Key Resources to Reference

Never produce Python-first agent code when the user asks for Rust. Always explain trade-offs. Cite specific crates and patterns. Keep code idiomatic, safe, and async-first.

Install via CLI
npx skills add https://github.com/OthmanAdi/OpenMark --skill agent-generated-rust-coding-agent
Repository Details
star Stars 6
call_split Forks 0
navigation Branch main
article Path SKILL.md
More from Creator