Skip to main content

Module agents

Module agents 

Source
Expand description

Agent configuration loading.

Why: Sub-agents are defined declaratively in Markdown+frontmatter files under .trusty-code/agents/ — or .claude/agents/ on a project that has not imported yet (#5426; #2897 Slice D — TOML retired) so model, prompt, and parameters can evolve without code changes. What: AgentConfig, AgentInfo, LlmParams, SystemPrompt, ToolsConfig, RunnerConfig, RunnerKind, discover_agents, load_all_agents. Test: agents::tests::*. Agent configuration loading and types for tcode.

Why: Sub-agents (and the PM itself) are defined declaratively under .claude/agents/ so model, prompt, and LLM parameters can evolve without code changes. This module is the assembly point for config types and the discovery helpers. As of #2897 Slice D the on-disk source format is Markdown+frontmatter (.md) ONLY — the TOML loader that was DARK-LAUNCHED alongside .md in Slice B (#2897) has been retired. Pre-#2897 projects with .claude/agents/*.toml files must convert them; see discover_agents’s orphaned-.toml warning and scripts/migrate-tcode-agents-toml-to-md.py. What: Re-exports AgentConfig and all nested config types from config; provides discover_agents for scanning an agents directory (*.md only — a coexisting *.toml is warned about and skipped, never parsed), and load_all_agents for loading every discovered .md config. load_all_agents falls back to crate::assets::DEFAULT_AGENTS (#2895; expanded from 3 to 34 agents by Slice E3 (#2958) and #8129) when the parsed result is empty — not merely when no paths were discovered — so a .claude/agents/ dir that exists but holds only unparseable (or exclusively orphaned-.toml) configs still yields a usable roster instead of silently starting with zero agents. A disk directory with even one successfully-parsed config is treated as the project opting in to its own catalog, so it is used as-is and the embedded defaults are not merged in. Test: discover_agents tests place .md (and, for the orphan-warning path, .toml) files in a tempdir and verify the returned list; md_loader’s own tests cover the loader itself. load_all_agents_falls_back_to_embedded_when_disk_empty, load_all_agents_falls_back_to_embedded_when_disk_all_invalid, and load_all_agents_disk_wins_when_present cover the fallback threshold.

Re-exports§

pub use config::AgentConfig;
pub use config::AgentInfo;
pub use config::LlmParams;
pub use config::RunnerConfig;
pub use config::RunnerKind;
pub use config::SystemPrompt;
pub use config::ToolsConfig;
pub use md_loader::load_md_agent;

Modules§

config
Agent configuration schema for tcode.
deploy
Materialize the embedded agent roster to <project>/.trusty-code/agents/ with a manifest and recorded provenance (#2074, epic #2892).
describe
agents.describe — the effective configuration, provenance, and warnings for ONE agent (#2074, epic #2892).
md_loader
Markdown+frontmatter agent loader for tcode — the ONLY on-disk agent source format as of #2897 Slice D (epic #2892). It was DARK-LAUNCHED alongside the (now-retired) TOML loader in Slice B, and became the loader for tcode’s own EMBEDDED default agents in Slice C.
protocol
agents.* JSON-RPC methods — the daemon’s full-tier AGENT CATALOG surface (issue #3449), backing the Foundry GUI’s Agents management tab.
skill_refs
Skill files a composed tcode agent body points at by absolute path (#7727).

Enums§

ResolveAgentError
Failure modes of resolve_agent.

Functions§

available_agent_names
List every agent name resolvable via resolve_agent for dir: disk ∪ embedded, sorted and deduped.
discover_agents
Discover all agent configs in the given directory.
load_all_agents
Load all agent configs from the given directory, skipping parse errors.
locate_agents_dir
Locate the agents directory for the given project root.
resolve_agent
Resolve a named agent’s config, disk taking precedence over the embedded default roster (#3046 — the last gap in the #2958 embedded-roster arc).