As a work item moves through its lifecycle, accumulate a running context document that grows with each phase.
Work Item #42 Context:
├── Planner reasoning: "Split into 3 tasks because auth module has circular deps..."
├── Implementor attempt 1: blocked — "Cannot resolve import cycle without touching module X"
├── Human note: "Module X refactoring is tracked in #38, use the interface adapter pattern"
├── Implementor attempt 2: completed — patch submitted
├── Reviewer feedback: "Missing error handling in token refresh path"
└── Implementor attempt 3: completed — addressed review comments
How to build it:
Each phase naturally produces a concise artifact:
- Planner: Already produces structured output with reasoning. Store a summary field.
- Implementor: ImplementorResult has an outcome and could carry a summary field ("what I did and why").
- Reviewer: ReviewerResult already has comments. These are the context.
- Human actions: When the human transitions status via TUI, prompt for an optional note (one text field).
Store this as an ordered list of entries on the work item (in state, maybe persisted to the issue body or a GitHub comment thread). Feed the full context to any agent that works on this work
item.
When to summarize: Only if the context exceeds a token threshold. At that point, yes, you'd use a cheap/fast model call (Haiku) to compress earlier entries while preserving the latest ones
in full. But for most work items (2-4 lifecycle transitions), raw context will fit comfortably.
Concrete implementation: Add a contextLog: ContextEntry[] field to your AgentRun or WorkItem type. Each handler that produces a result appends an entry. Context assembly reads the log when
building agent prompts. Store it in GitHub issue comments as a persistent record.