Problem
Sub-agents spawned via spawn_agent do not receive the embedded AGENTS.md operating rules layer that main-agent sessions get. They only receive their own markdown body, optional project instructions (from the workspace directory), and the hardcoded HeadlessExecutionContract.
This means sub-agents operate without the core safety guardrails that main agents inherit:
- Grounding rules (e.g., "Never state runtime facts without checking with a tool")
- Search/citation policy (inline hyperlink requirements, when to search vs. answer)
- Safety boundaries (Resource Hard Deny awareness, "I don't know beats a confident wrong answer")
- Proactive check-back expectations
- Search decision rules
Sub-agents are autonomous, non-interactive workers. Running them without these guardrails is worse than running main agents without them — the sub-agent is acting on behalf of the parent session with no approval loop to catch misbehavior.
Current sub-agent prompt stack
Currently assembled in SubAgentActor.BuildSystemPrompt():
[Sub-Agent Markdown Body]
[Skill Overlay (if routed via metadata.subagent)]
[HeadlessExecutionContract]
Missing entirely:
- Embedded
AGENTS.md (operating rules, safety, grounding)
SOUL.md (personality/tone)
TOOLING.md (host capabilities)
Project instructions (AGENTS.md/CLAUDE.md/CONTEXT.md from workspace) do load correctly via ResolveProjectInstructions() in SubAgentSpawner.cs.
Proposed prompt stack
[Embedded AGENTS.md] — base operating rules, safety, grounding
[SOUL.md] — tone/communication style (optional)
[TOOLING.md] — host capabilities (likely redundant, tool index already available)
[Project instructions] — workspace/domain context (already works)
[Sub-agent Markdown Body] — role definition, what it does
[Skill Overlay] — skill-specific context if routed
[HeadlessExecutionContract] — execution contract, always at the bottom
Implementation sketch
In SubAgentActor.BuildSystemPrompt(), instead of:
var basePrompt = string.IsNullOrWhiteSpace(definition.ProjectInstructions)
? definition.SystemPrompt
: SystemPromptAssembler.Assemble(
agents: definition.SystemPrompt,
projectInstructions: definition.ProjectInstructions);
Pass the embedded AGENTS.md and other identity layers through SystemPromptAssembler.Assemble(), then append the sub-agent markdown body, then the HeadlessExecutionContract.
The embedded AGENTS.md can be read from CachedAgents.Value (same source used by FileSystemPromptProvider), and project instructions already resolve from definition.ProjectInstructions.
Code locations
SubAgentActor.BuildSystemPrompt() — prompt assembly (main change)
SubAgentSpawner.ResolveProjectInstructions() — already works, no change needed
SubAgentDefinition — may need additional fields or a different assembly approach
FileSystemPromptProvider.GetSystemPrompt() — reference for how main agents assemble their prompt
Notes
- The
HeadlessExecutionContract is currently hardcoded in SubAgentActor and should remain appended at the end
SOUL.md and TOOLING.md may be worth including but are lower priority — the critical missing layer is embedded AGENTS.md
- This is a prompt-layering change only, no API or protocol changes
Problem
Sub-agents spawned via
spawn_agentdo not receive the embeddedAGENTS.mdoperating rules layer that main-agent sessions get. They only receive their own markdown body, optional project instructions (from the workspace directory), and the hardcodedHeadlessExecutionContract.This means sub-agents operate without the core safety guardrails that main agents inherit:
Sub-agents are autonomous, non-interactive workers. Running them without these guardrails is worse than running main agents without them — the sub-agent is acting on behalf of the parent session with no approval loop to catch misbehavior.
Current sub-agent prompt stack
Currently assembled in
SubAgentActor.BuildSystemPrompt():Missing entirely:
AGENTS.md(operating rules, safety, grounding)SOUL.md(personality/tone)TOOLING.md(host capabilities)Project instructions (
AGENTS.md/CLAUDE.md/CONTEXT.mdfrom workspace) do load correctly viaResolveProjectInstructions()inSubAgentSpawner.cs.Proposed prompt stack
Implementation sketch
In
SubAgentActor.BuildSystemPrompt(), instead of:Pass the embedded AGENTS.md and other identity layers through
SystemPromptAssembler.Assemble(), then append the sub-agent markdown body, then theHeadlessExecutionContract.The embedded AGENTS.md can be read from
CachedAgents.Value(same source used byFileSystemPromptProvider), and project instructions already resolve fromdefinition.ProjectInstructions.Code locations
SubAgentActor.BuildSystemPrompt()— prompt assembly (main change)SubAgentSpawner.ResolveProjectInstructions()— already works, no change neededSubAgentDefinition— may need additional fields or a different assembly approachFileSystemPromptProvider.GetSystemPrompt()— reference for how main agents assemble their promptNotes
HeadlessExecutionContractis currently hardcoded inSubAgentActorand should remain appended at the endSOUL.mdandTOOLING.mdmay be worth including but are lower priority — the critical missing layer is embedded AGENTS.md