Summary
Remove readPostCompactionContext() and its injection in agent-runner.ts. This is Pi-era layer blurring — the middleware reads AGENTS.md from the workspace directory and injects it into agent context after conversation compaction. CLI agents manage their own context; middleware should not read workspace files to inject into agent sessions.
This item is independent of the template/workspace cleanup chain — it can be done in parallel.
What to Delete
src/auto-reply/reply/post-compaction-context.ts (~118 lines) — contains readPostCompactionContext() which reads AGENTS.md from workspace and builds a system event
src/auto-reply/reply/post-compaction-context.test.ts
What to Modify
src/auto-reply/reply/agent-runner.ts — remove readPostCompactionContext import and its injection at approximately L669-684 (the block that reads workspace AGENTS.md and prepends it as a system event after compaction)
What to Evaluate
src/auto-reply/reply/post-compaction-audit.ts — check if it has callers beyond the post-compaction injection. If it only serves the deleted pipeline, delete it too. If it has independent uses (e.g., general audit functionality), keep it.
Acceptance Criteria
Context
readPostCompactionContext() reads AGENTS.md from the workspace using the same workspace resolution as other Pi-era code. It builds a "system" event containing the file's content and injects it into the conversation after compaction.
- This was designed for the Pi-embedded execution model where the middleware controlled the agent's context window. In the AgentRuntime/ChannelBridge architecture, CLI agents manage their own compaction and context.
- The injection point in
agent-runner.ts is in the compaction/context-building section — look for imports from post-compaction-context.js.
Summary
Remove
readPostCompactionContext()and its injection inagent-runner.ts. This is Pi-era layer blurring — the middleware reads AGENTS.md from the workspace directory and injects it into agent context after conversation compaction. CLI agents manage their own context; middleware should not read workspace files to inject into agent sessions.This item is independent of the template/workspace cleanup chain — it can be done in parallel.
What to Delete
src/auto-reply/reply/post-compaction-context.ts(~118 lines) — containsreadPostCompactionContext()which reads AGENTS.md from workspace and builds a system eventsrc/auto-reply/reply/post-compaction-context.test.tsWhat to Modify
src/auto-reply/reply/agent-runner.ts— removereadPostCompactionContextimport and its injection at approximately L669-684 (the block that reads workspace AGENTS.md and prepends it as a system event after compaction)What to Evaluate
src/auto-reply/reply/post-compaction-audit.ts— check if it has callers beyond the post-compaction injection. If it only serves the deleted pipeline, delete it too. If it has independent uses (e.g., general audit functionality), keep it.Acceptance Criteria
post-compaction-context.tsand its test file are deletedagent-runner.tsno longer imports or callsreadPostCompactionContextpost-compaction-audit.tsevaluated — deleted if no other callers, kept if independently usedgrep -ri "readPostCompactionContext\|post-compaction-context" src/returns zero hits (excluding the audit file if kept)Context
readPostCompactionContext()readsAGENTS.mdfrom the workspace using the same workspace resolution as other Pi-era code. It builds a "system" event containing the file's content and injects it into the conversation after compaction.agent-runner.tsis in the compaction/context-building section — look for imports frompost-compaction-context.js.