Skip to content

fix(cleanup): preserve original error context when recovering stale executions (#286) - #324

Merged
vybe merged 1 commit into
mainfrom
feature/286-preserve-error-context
Apr 14, 2026
Merged

fix(cleanup): preserve original error context when recovering stale executions (#286)#324
vybe merged 1 commit into
mainfrom
feature/286-preserve-error-context

Conversation

@vybe

@vybe vybe commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds /api/executions/{id}/last-error endpoint to agent server that extracts error context from log buffer
  • Updates cleanup service watchdog to fetch original error before marking executions failed
  • Combines original error with cleanup reason for full diagnostic context
  • Sanitizes error messages to prevent credential leakage

Changes

  • docker/base-image/agent_server/routers/chat.py - New endpoint
  • docker/base-image/agent_server/services/process_registry.py - get_last_error() method
  • src/backend/services/cleanup_service.py - _get_execution_error() and updated _recover_execution()
  • tests/test_watchdog_unit.py - 9 new unit tests
  • docs/memory/feature-flows/cleanup-service.md - Updated documentation

Test Plan

  • Unit tests pass: pytest tests/test_watchdog_unit.py -v (27 tests)
  • Integration test: trigger a stale execution with a known error and verify error context preserved
  • Manual verification: check cleanup logs show combined error messages

Closes #286

🤖 Generated with Claude Code

…xecutions (#286)

The cleanup service now queries the agent's log buffer for original error
context before marking executions as failed. This preserves diagnostic info
like expired tokens, OOM errors, and crash details instead of replacing
them with generic "Stale execution" messages.

Changes:
- Add /api/executions/{id}/last-error endpoint to agent server
- Add ProcessRegistry.get_last_error() to scan log buffer for errors
- Update _recover_execution() to fetch and combine error context
- Sanitize error messages to prevent credential leakage
- Truncate combined messages to 2000 chars to prevent DB bloat

Closes #286

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vybe
vybe merged commit c96c80f into main Apr 14, 2026
vybe added a commit that referenced this pull request Apr 14, 2026
PR #324 landed — cleanup service now preserves original error context
by fetching from agent log buffer before marking executions failed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
vybe added a commit that referenced this pull request Apr 14, 2026
Shipped:
- #95 (PR #320) - unified TaskExecutionService
- #285 (PR #322) - auth failure fast-fail
- #226 (PR #323) - per-agent slot TTL
- #286 (PR #324) - preserve error context

Remaining: #61, #132, #56

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: stale execution cleanup loses original error context — no way to diagnose failure cause

1 participant