feat(FN-1877): add auto-compaction on context window errors to promptWithFallback
- Detect context-window-limit errors from AI sessions and automatically compact the session conversation history before retrying (one attempt per session) - Centralize auto-compaction in promptWithFallback (pi.ts) so executor, merger, and step-session-executor all benefit from the same mechanism - Remove scattered context-limit error handling from executor.ts, merger.ts, and step-session-executor.ts in favor of the centralized approach - Add comprehensive tests for auto-compaction retry behavior in pi.test.ts - Remove unused compactSessionContext import from step-session-executor.ts - Add memory note documenting the centralized auto-compaction design
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
## Architecture
|
||||
|
||||
- `TaskExecutor` terminates active agent sessions (single and step) when tasks are moved away from `in-progress` via the `task:moved` event handler. This prevents zombie sessions when users manually send tasks back to todo/triage from the board UI.
|
||||
- **Centralized Context-Window Auto-Compaction (FN-1877)**: The `promptWithFallback()` function in `packages/engine/src/pi.ts` automatically catches context-window overflow errors, runs `compactSessionContext()`, and retries once. This centralizes recovery for ALL agent types (executor, step-session, merger, triage, heartbeat, reviewer, mission-execution-loop). Callers that previously had duplicate compact-and-resume logic (executor, step-session-executor, merger) have been simplified to use `promptWithFallback`'s auto-compaction as first-level recovery, with their own reduced-prompt fallbacks as second-level recovery. This eliminates code duplication and ensures consistent recovery behavior.
|
||||
- **Workflow Step Revision Loop (FN-1499)**: Workflow steps can request implementation revisions via "REQUEST REVISION" output. The flow:
|
||||
1. Workflow step agent outputs "REQUEST REVISION\n\n[feedback]" to signal that code changes are needed
|
||||
2. `executeWorkflowStep()` detects this pattern and returns `WorkflowStepOutcome` with `revisionRequested: true`
|
||||
|
||||
Reference in New Issue
Block a user