thndrs-agent
thndrs-agent is an experimental, provider-neutral Rust library for authors of
coding-agent applications.
It provides a small vocabulary for iterations of agent loops, namely messages in, semantic events out, tool requests, permission decisions, and cooperative cancellation.
Use it when your application owns the model client and tool policy but you want the rest of the agent loop to speak small, typed Rust values.
A terminal UI, web service, or editor integration can all consume the same events without importing a provider's wire types.
Installation
Add it to your crate or workspace's Cargo.toml:
[]
= "0.1"
= "1"
Describe a Turn
Build an AgentTurn from your application's conversation and tool catalog,
then lower it in your provider adapter.
The provider adapter returns AgentEvent values as work progresses.
use ;
let turn = new;
assert_eq!;
assert_eq!;
AgentRun is a small helper for a background run. Give it a closure that
sends your event type and checks the supplied CancelToken. Then, consume
the receiver in the UI or transport that owns presentation.
Control Context
context provides pure, deterministic context control for agent turns:
- typed candidate items
- token budgets
- selection
- compact ledgers
- compaction policy.
Hosts supply project instructions, transcript entries, skills, and pins.
Modules
adapterscontains application-owned permission and execution callbacks.budgetbounds tool batches and continuation segments.cancelprovides a shared cooperative cancellation token.contextcontains pure selection, control, and compaction policy.contractsdefines provider-neutral messages, events, tools, and retry values.runowns a background run's event channel and cancellation handle.
Keep Policy in your application
This crate does not read files, run processes, or contact a model provider.
Use ToolPermissionHook when your application must approve a sensitive tool
call, and ToolExecutionHook when it needs to take over execution. The
application context and result types remain yours.