Swink Agent
A pure-Rust library for building LLM-powered agentic loops. Provider-agnostic core with pluggable streaming, concurrent tool execution, and lifecycle events.
Workspace
| Crate | Type | Purpose |
|---|---|---|
swink-agent |
lib | Agent loop, tool system, streaming traits, retry, error types |
swink-agent-adapters |
lib | StreamFn adapters — Anthropic, OpenAI, Google Gemini, Ollama, Azure, xAI, Mistral, Bedrock |
swink-agent-policies |
lib | 10 feature-gated policy implementations (budget, sandbox, PII, audit, etc.) |
swink-agent-memory |
lib | Session persistence, summarization compaction |
swink-agent-local-llm |
lib | On-device inference — SmolLM3-3B (default), Gemma 4 (opt-in gemma4 feature), EmbeddingGemma-300M (embeddings) |
swink-agent-eval |
lib | Evaluation harness — efficiency scoring, budget guards, gate checks, audit trails |
swink-agent-artifacts |
lib | Versioned artifact storage (filesystem + in-memory backends) |
swink-agent-auth |
lib | OAuth2 credential management and refresh |
swink-agent-mcp |
lib | Model Context Protocol integration (stdio/SSE) |
swink-agent-patterns |
lib | Multi-agent orchestration patterns (pipeline, parallel, loop) |
swink-agent-plugin-web |
lib | Web browsing and search plugin |
swink-agent-macros |
proc-macro | #[derive(ToolSchema)] and #[tool] proc macros |
swink-agent-tui |
lib + bin | Interactive terminal UI with markdown, syntax highlighting, tool panel |
Key Ideas
StreamFnis the only provider boundary — implement it to add a new LLM backend.AgentTooltrait + JSON Schema validation for tool definitions.- Tools execute concurrently within a turn; steering callbacks can interrupt mid-batch.
- Errors stay in the message log — the loop keeps running. Typed
AgentErrorvariants for callers. - Events are push-only (
AgentEventstream). No inward mutation through events. - No
unsafecode. No global mutable state.
Quick Reference
Example: Build a Custom Agent
Wire up an LLM provider, register tools, and launch the interactive TUI — all in one file:
use ;
use build_remote_connection_for_model;
use default_local_connection;
use ;
async
More Examples
Runnable examples are in SuperSwinkAI/Swink-Agent-Examples:
| Example | What it demonstrates |
|---|---|
simple_prompt |
Create an Agent with a mock stream function, send a prompt, print the result |
with_tools |
Register BashTool / ReadFileTool / WriteFileTool and wire up the approval callback |
custom_adapter |
Implement the StreamFn trait for a custom provider |
custom_agent |
Full agent with Anthropic adapter, tools, and interactive TUI |
See docs/getting_started.md for setup and configuration. See docs/architecture/HLD.md for system design. See docs/planning/PRD.md for product requirements.