Skip to content

GUT post-compaction AGENTS.md injection #258

@alexey-pelykh

Description

@alexey-pelykh

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

  • post-compaction-context.ts and its test file are deleted
  • agent-runner.ts no longer imports or calls readPostCompactionContext
  • post-compaction-audit.ts evaluated — deleted if no other callers, kept if independently used
  • grep -ri "readPostCompactionContext\|post-compaction-context" src/ returns zero hits (excluding the audit file if kept)
  • Build passes, existing tests pass

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions