Skip to content

Keep active turns running until session settles#2517

Open
hogeheer499-commits wants to merge 1 commit intopingdotgg:mainfrom
hogeheer499-commits:fix/keep-active-turns-running
Open

Keep active turns running until session settles#2517
hogeheer499-commits wants to merge 1 commit intopingdotgg:mainfrom
hogeheer499-commits:fix/keep-active-turns-running

Conversation

@hogeheer499-commits
Copy link
Copy Markdown

@hogeheer499-commits hogeheer499-commits commented May 5, 2026

What changed

  • Keep a projected turn in running while the thread session still reports that same turn as active.
  • Complete or error the latest running turn when the session settles instead of completing it from every non-streaming assistant message.
  • Reopen a stale completed turn if a later running session update reports that turn as active again.
  • Add a regression test that covers both live projection and replay from the event log.

Why this should exist

This is a focused server projection correctness fix.

A local T3 Code 0.0.22 desktop state showed this inconsistent projection:

projection_thread_sessions.status = running
projection_thread_sessions.active_turn_id = 019df64c-8cf7-79f0-8b0f-7591e0dbbbbc
projection_turns.state for active turn = completed
projection_turns.completed_at = 2026-05-05T04:01:59.270Z
provider_session_runtime.status = running
provider_session_runtime.runtime_payload.activeTurnId = 019df650-a59b-7fa3-870e-b47ea9d1bf61
later assistant messages for the completed turn = yes

The event stream showed a running session, then a non-streaming assistant message for the active turn, then more provider activity. The old projection logic treated that non-streaming assistant message as final turn completion. That is too early for providers that emit non-streaming assistant segments during longer work.

The regression test mirrors that sequence. It then deletes the projection rows and bootstraps from the event log again, so the test covers both online projection and replay.

Scope

Validation

  • npx --yes [email protected] run --filter t3 test src/orchestration/Layers/ProjectionPipeline.test.ts - 19 passed
  • npx --yes [email protected] run --filter t3 test src/orchestration/Layers/ProviderRuntimeIngestion.test.ts - 38 passed
  • npx --yes [email protected] run --filter t3 test - 121 files passed, 961 tests passed, 1 file / 4 tests skipped
  • npx --yes [email protected] run fmt:check - passed
  • npx --yes [email protected] run lint - 0 errors, existing warnings only
  • npx --yes [email protected] run --filter t3 typecheck - exit 0, existing Effect language-service messages only

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 80c57c3e-4b66-4029-a9ec-d6c21b4f6e9f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels May 5, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 5, 2026

Approvability

Verdict: Needs human review

This PR modifies the turn state machine in the orchestration projection pipeline, changing when turns transition from 'running' to 'completed'. This is a significant runtime behavior change to core orchestration logic that warrants human review.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants