- Rename loopConfig→agentConfig, agentCore→agent, loopcfg→cfg, systemPrompt→preamble
for clarity: the struct represents agent runtime config, the field is its config,
and preamble accurately describes the compiled system+agent prompt sent as system role
- Separate preamble from agent context: preamble now contains only SYSTEM_PROMPT.md;
agent prompt and agentSpawn hook output are injected into session history at
context refresh points instead of being bolted onto the system role
- Replace fireAgentSpawn (mutated preamble once, guarded by agentSpawnFired flag)
with spawnContext (assembles agent prompt + hook output, returns string for caller
to inject); remove agentSpawnFired entirely — session==nil is the sufficient guard
- Three refresh points inject spawn context into session history:
session start, post-clear (session=nil triggers same path), post-compaction
(auto and manual)
- Move all preTurn tool primes (tools-file, tools-reasoning, tools-memory,
tools-subagent, tools-elevate) to agentSpawn in all agent configs so they are
injected at session refresh points alongside bd prime, not repeated every turn
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>