Skip to main content

Module subagent_contract

Module subagent_contract 

Source
Expand description

Sub-agent context contracts (GL#450).

A briefing pack is the contract between a parent agent and a sub-agent: task, token budget, the facts the sub-agent needs, and the return format it must produce. Packs are deterministic — same input, byte-identical output — so they can be diffed, cached, and replayed. The return channel is the inverse: a sub-agent reports category/key: value lines, which the parent distills into recallable knowledge facts instead of raw transcript.

Structs§

ContractFact
SubAgentContractV1
Versioned briefing pack. Field order is fixed by this struct; serialization uses serde_json::to_string_pretty which preserves struct order, keeping the bytes stable across runs.

Constants§

RETURN_FORMAT_V1
Instruction embedded in every pack telling the sub-agent how to report.

Functions§

build_briefing_pack
Build a deterministic briefing pack: task + the most relevant current facts, greedily filled (in stable relevance order) until budget_tokens is reached. The task itself is always included; the budget governs facts.
parse_return_lines
Parse sub-agent return lines (category/key: value) into structured facts. Lines that don’t match the contract format are reported back as rejects instead of being silently dropped.
serialize_pack
Serialize a pack with stable formatting (struct field order, pretty JSON).