Skip to content

fix(eve): terminate turns on cancellation and session failure - #500

Merged
HugoRCD merged 2 commits into
mainfrom
evl-215
Aug 6, 2026
Merged

fix(eve): terminate turns on cancellation and session failure#500
HugoRCD merged 2 commits into
mainfrom
evl-215

Conversation

@HugoRCD

@HugoRCD HugoRCD commented Aug 5, 2026

Copy link
Copy Markdown
Owner

🔗 Linked issue

📚 Description

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Summary by CodeRabbit

  • New Features

    • Added handling for cancelled AI turns, which now emit a dedicated cancellation event with status 499.
    • Open turns are automatically finalized when a session completes or fails, ensuring cancellation and failure details are recorded consistently.
    • Session context is cleared after completion or eviction, preventing information from carrying over into later sessions.
  • Documentation

    • Added release documentation describing cancellation handling and turn cleanup behavior.

@HugoRCD HugoRCD self-assigned this Aug 5, 2026
@changeset-bot

changeset-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: be73216

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
evlog Patch
@evlog/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
evi Ready Ready Preview Aug 6, 2026 7:38am
evlog-docs Ready Ready Preview, v0 Aug 6, 2026 7:38am
evlog-render-lab Ready Ready Preview Aug 6, 2026 7:38am
evlog-telemetry Ready Ready Preview Aug 6, 2026 7:38am
just-use-evlog Ready Ready Preview Aug 6, 2026 7:38am

Request Review

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Eve now tracks open turns per session. Cancelled turns finish with status 499 and phase cancelled. Session completion and failure flush open turns and clear session context. Tests cover cancellation, flushing, logger cleanup, and context isolation.

Changes

Eve turn lifecycle

Layer / File(s) Summary
Open-turn tracking and finalization
packages/evlog/src/eve/index.ts
Eve tracks open turn IDs, derives the cancelled phase, removes finalized turns, and clears tracking during cleanup and reset.
Session terminal event handling
packages/evlog/src/eve/index.ts, .changeset/eve-terminate-cancelled-turns.md
Cancellation uses status 499. Session completion finishes remaining turns successfully. Session failure attaches error details and finishes remaining turns with status 500.
Cancellation and session cleanup validation
packages/evlog/test/eve.test.ts
Tests cover cancellation metadata, logger cleanup, failed-session flushing, completion flushing, and removal of carried-over session context.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant EveEvents as Eve event handlers
  participant EveState as Eve session state
  participant TurnLogger as turn logger
  EveEvents->>EveState: register open turn
  EveEvents->>TurnLogger: handle turn.cancelled
  TurnLogger->>EveState: finish turn with status 499
  EveEvents->>TurnLogger: handle session.completed or session.failed
  TurnLogger->>EveState: finish remaining open turns
  EveState->>EveState: clear session context
Loading

Possibly related PRs

  • HugoRCD/evlog#501: Implements related cancellation and open-turn cleanup changes in Eve and its tests.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The template headings are present, but the main description is empty and the checklist contains no completed items. Add a description of the problem and solution, then complete the applicable checklist items and link any related issue or documentation.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the Eve cancellation and session-failure fix and follows the repository's conventional commit format.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch evl-215

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Aug 5, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@evlog/cli@500
npm i https://pkg.pr.new/evlog@500
npm i https://pkg.pr.new/@evlog/nuxthub@500
npm i https://pkg.pr.new/@evlog/telemetry@500

commit: be73216

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 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 `@packages/evlog/src/eve/index.ts`:
- Around line 872-900: Update the 'session.completed' and 'session.failed'
handlers to guarantee clearSessionState(ctx.session.id) runs even when turn
cleanup rejects. Handle each open turn’s finish operation independently so one
rejection does not prevent remaining turns from being processed, and move
session cleanup into a finally block while preserving the existing error
logging.

In `@packages/evlog/test/eve.test.ts`:
- Around line 361-390: Update the test named “drops session context once the
session completes” to leave the initial turn open by removing its turn.completed
event, then emit session.completed and assert that finishOpenTurns drains a
status-200 event and useLogger(toolContext()) fails. Preserve the subsequent
new-turn assertion to verify session context is not retained, and ensure the
added behavior has explicit test coverage.
🪄 Autofix

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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 2f889b32-c57e-4e1c-b167-1ae8e669a221

📥 Commits

Reviewing files that changed from the base of the PR and between 3c02e33 and 0eb5c12.

📒 Files selected for processing (3)
  • .changeset/eve-terminate-cancelled-turns.md
  • packages/evlog/src/eve/index.ts
  • packages/evlog/test/eve.test.ts

Comment thread packages/evlog/src/eve/index.ts
Comment thread packages/evlog/test/eve.test.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant