Module agents

Module agents 

Source
Expand description

Agent system for MCP prompts and personas.

Agents are named personas that combine a system prompt, scoped tools, and optional dynamic context injection. They enable “assume a role” workflows in Cursor, Claude Desktop, and other MCP clients.

§Architecture

┌──────────────────────────────────────────┐
│            AgentRegistry                 │
│  ┌─────────┐ ┌─────────┐ ┌────────────┐ │
│  │  TOML   │ │  Lua    │ │  Custom    │ │
│  │ Inline  │ │ Script  │ │ (Rust)     │ │
│  └─────────┘ └─────────┘ └────────────┘ │
└──────────────┬───────────────────────────┘
               ▼
  GET /agents/list  ·  POST /agents/{name}/prompt

§Agent Sources

SourceConfig KeyStruct
Inline TOML[agents.inline.<name>]TomlAgent
Lua script[agents.script.<name>]LuaAgentAdapter (in crate::agent_script)
Custom Rustregistry.register(...)User-defined Agent impl

§Usage

use context_harness::agents::{AgentRegistry, TomlAgent};

let mut agents = AgentRegistry::new();
agents.register(Box::new(TomlAgent::new(
    "reviewer".to_string(),
    "Reviews code against conventions".to_string(),
    vec!["search".to_string(), "get".to_string()],
    "You are a senior code reviewer.".to_string(),
)));

See docs/AGENTS.md for the full specification.

Structs§

AgentArgument
An argument that an agent accepts.
AgentInfo
Serializable agent info for the /agents/list endpoint.
AgentPrompt
A resolved agent prompt ready for the LLM.
AgentRegistry
Registry for agents (TOML, Lua, and custom Rust).
PromptMessage
A message to inject into the conversation.
TomlAgent
An agent defined inline in TOML configuration.

Traits§

Agent
An agent persona that provides a system prompt and tool scoping.