fix(agent): preserve failed context#1608
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR preserves failed message context to help agents recover from errors. It introduces an eligibility predicate to classify context-eligible records (sent user messages and assistant error messages), formats error reasons into readable summaries, integrates these summaries into chat message conversion and compaction logic, and updates history selection across context building, compaction, and runtime components. ChangesFailed Message Context Preservation
Sequence Diagram(s)sequenceDiagram
participant User
participant DB as MessageStore
participant Presenter as recordToChatMessages
participant Formatter as formatAssistantErrorSummary
participant Compactor as prepareCompaction
User->>DB: prior assistant/error records persisted
DB->>Presenter: fetch candidate records (isContextHistoryRecord)
Presenter->>Formatter: extract & format error reasons
Formatter-->>Presenter: formatted summary
Presenter->>Compactor: pass history (with appended error summaries)
Compactor-->>Presenter: compaction result / serialized assistant text
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main/presenter/agentRuntimePresenter/compactionService.ts`:
- Around line 184-187: serializeAssistantRecord currently only pushes a failure
summary when formatAssistantErrorSummary(errorMessages) returns a value, causing
compaction to omit failure context for records where record.status === 'error'
but no explicit error blocks exist; update serializeAssistantRecord so that
after computing errorSummary from formatAssistantErrorSummary(errorMessages) you
check if record.status === 'error' and errorSummary is falsy, then push the same
"unknown failure" fallback used by recordToChatMessages (or construct an
equivalent assistant:error summary) into lines to keep compaction output in sync
with runtime context.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 69fd93b1-d486-403c-b166-40a0fafd6dc4
📒 Files selected for processing (8)
docs/issues/failed-message-context/plan.mddocs/issues/failed-message-context/spec.mddocs/issues/failed-message-context/tasks.mdsrc/main/presenter/agentRuntimePresenter/compactionService.tssrc/main/presenter/agentRuntimePresenter/contextBuilder.tssrc/main/presenter/agentRuntimePresenter/index.tstest/main/presenter/agentRuntimePresenter/compactionService.test.tstest/main/presenter/agentRuntimePresenter/contextBuilder.test.ts
Summary
Tests
Summary by CodeRabbit
New Features
Documentation
Tests