Skip to main content

Module md_loader

Module md_loader 

Source
Expand description

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.

Why: trusty-agents-common’s agents::builder compose machinery (Slice A, #2952) already resolves extends: inheritance chains for trusty-mpm’s .md agent format and now carries max_tokens/tools frontmatter fields that mirror tcode’s AgentConfig schema. Rather than fork a second .md parser, tcode reuses that composer and projects its output onto its existing AgentConfig. Slice C (#2897) additionally routes crate::assets::DEFAULT_AGENTS’s embedded fallback through this module: the embedded strings have no source directory to resolve an extends: chain against (they are compiled-in &'static str, not files on disk), so [project_embedded_md] skips compose_agent entirely and calls agent_metadata_from_str/[extract_body] directly on the raw string — both are already string-in, string/struct-out, so no file-path dependency stands in the way. The two entry points (load_md_agent for disk, [project_embedded_md] for embedded strings) share the exact same [project_to_agent_config] mapping, so there is only ever one frontmatter -> AgentConfig projection to maintain. What: load_md_agent reads a .md agent source file, calls trusty_agents_common::agents::builder::compose_agent to resolve its extends: chain into one flattened document, projects the composed frontmatter (via agents::metadata::agent_metadata_from_str) and prose body onto tcode’s AgentConfig. [project_embedded_md] does the same projection for an in-memory &'static str with no extends: resolution. Test: load_md_agent_base_case, tools_projection_* (the Option<Vec<String>> direct-map), hr1_initial_prompt_not_leaked_into_body (the HR-1 guard), assets::tests::* (embedded-default field-identity vs. the retired TOML fixtures, kept as a historical regression pin).

Functions§

load_md_agent
Load a tcode AgentConfig from a .md agent source file.
project_embedded_md_with_extends
Project an embedded tm-catalog agent onto tcode’s AgentConfig, resolving its extends: chain entirely against crate::assets::EMBEDDED_TM_AGENT_SOURCES – no filesystem access (Slice E2, #2958).