fix(server): dismiss orphaned provider questions #10586
main fromrefs/pull/10586/head·opened View on GitHubNative provider questions can outlive their session and leave clients offering answers that the provider can no longer accept. Session exit now dismisses native questions, including turnless questions. Answering a legacy question against a missing or stopped session also records a durable dismissal while retaining the failed-answer activity.
Dismissals use server time strictly after the stored request timestamp, so clock rollback or an older client timestamp cannot leave pending input set after restart. Repeated answers do not append duplicate resolutions. Asynchronous message-mode questions and transient failures from live sessions retain their existing behavior.
Validation: 131 focused ProviderCommandReactor and ProviderRuntimeIngestion tests pass. Missing/stopped-session timestamp regressions fail before the fix and pass afterward, including restart, durable pending state, and duplicate-resolution coverage. Scoped lint and server typecheck pass with existing warnings/suggestions. Rebased onto main.
Fixes #5454.
Model: GPT-6 Harness: Codex in T3 Code
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved at
8d7c4c0Macroscope's review found this PR approvable — This focused server fix cleans up orphaned native provider questions on session termination or unavailable sessions, while preserving message-mode behavior and adding targeted persistence and duplicate-resolution tests. Its runtime impact is localized to question lifecycle state, with no schema, deployment, security, billing, or static-analysis configuration changes.
Notes:
- Diff unchanged. Approvability was decided on eligibility alone.
All clear
Posted via Macroscope — Effect Service ConventionsNavigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
eafa0a07-85fe-42ed-ba66-5bfcf2f526ab📥 Commits
Reviewing files that changed from the base of the PR and between 8d7c4c08dd87043f263f91477fbe7a84d067eda5 and a3ae621c88557acb1358108355c7caedd61beceb.
📒 Files selected for processing (4)
apps/server/src/orchestration/Layers/ProviderCommandReactor.test.tsapps/server/src/orchestration/Layers/ProviderCommandReactor.tsapps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.tsapps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
📝 Walkthrough
Walkthrough#
Runtime ingestion resolves pending native user-input requests on session exit. The command reactor also dismisses matching non-message requests when a response arrives without an active provider session. Tests cover both paths, including persistence across harness restarts.
Changes#
Pending user-input lifecycle
Layer / File(s) Summary Session-exit dismissal
apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts,apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.tsSession exit resolves pending non-message requests across turns, including turnless requests. Dismissals retain each request’s original turnId. Tests cover answered requests, repeated exits, and asynchronous requests.Orphaned response handling
apps/server/src/orchestration/Layers/ProviderCommandReactor.ts,apps/server/src/orchestration/Layers/ProviderCommandReactor.test.tsWhen no provider session is active, the reactor records the response failure and resolves a matching durable non-message request. Tests cover missing, stopped, and running sessions, including recovery across harness restarts. Priority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers:
juliusmarminge,t3dotgg,maria-rcksMerge Risk: ⚪ Minimal · up to
a3ae6This backend change dismisses pending native questions when a provider session exits or is missing, so they no longer stay stuck. No merge-blocking risk was identified in the supplied context.
Security Architecture Review#
Security architecture risk: 🔵 Low · up to
a3ae6The inspected change dismisses stale questions rather than forwarding answers to ended sessions. Restart behavior is covered, but simultaneous answers and interrupted cleanup remain uncertain.
Retained concerns No architecture-level concerns identified.
Security review details
Security Blast Radius
- inferred — The inspected mutation scope is the addressed thread's native input lifecycle, potentially spanning multiple turns on session exit. This source establishes thread-local selection, not a complete tenant-isolation or authentication assessment.
Trust Boundaries and Controls
- observed — Client-supplied thread and request identifiers feed a parameterized durable lookup constrained by both identifiers. Cleanup requires a stored pending request and excludes message-mode input; an answer timestamp does not determine the new orphan-dismissal timestamp.
Resilience and Maintainability Implications
- observed — The engine serializes commands and transactionally commits each command's events, projections, and receipt. Each reactor also processes its own queue sequentially. These controls contain individual write failures, but do not establish atomicity between a lifecycle lookup and separate dismissal commands, or recovery after cleanup is interrupted.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
Check name Status Explanation Resolution Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold. ✅ Passed checks (4 passed)
Check name Status Explanation Title check ✅ Passed The title clearly and concisely describes the main change: dismissing orphaned provider questions. Description check ✅ Passed The description explains the problem, implementation, scope, linked issue, verification results, regression coverage, and agent details. Although it does not reproduce the template headings, it provid… Linked Issues check ✅ Passed [ #5454] The server appendsuser-input.resolvedfor pending native callback requests whensession.exitedoccurs. It covers parent, child, and turnless requests. It excludes `responseMode: "messag…Out of Scope Changes check ✅ Passed The production changes directly implement [ #5454]. The persistence harness changes support restart and durable-state tests. The added tests verify terminal dismissal, timestamp ordering, idempotence, …- Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create a new PR
Comment `@coderabbitai help` to get the list of available commands.All clear
Posted via Macroscope — Effect Service ConventionsNote: GPT-6 on behalf of shivam (@shivamhwp).
The missing/stopped-session dismissal copies the client response timestamp. When that timestamp precedes the original question, the durable activity query still returns
user-input.requested: its activities have no sequence, so the query falls back tocreated_at. The client hides the resolved prompt, but the server keepshasPendingUserInputtrue, and another response appends a second dismissal.Use a server-generated dismissal timestamp strictly after the stored request timestamp for both the activity and append command. Keep the durable lookup and the message-mode/live-session guards. The dismissal needs to remain the latest request activity after a restart and repeated answers must not add more resolutions.
juliusmarminge added labelsmacroscope-review
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
All clear
Posted via Macroscope — Effect Service ConventionsFixed in the current head. Dismissal uses server time strictly after the persisted request timestamp for both the activity and append command. The regression covers a stale client timestamp, restart, and repeated answers without a second dismissal.
Thanks for working on this. We merged the orchestrator V2 rewrite in #2829, and we are closing this PR as part of that transition.
This change touches ProviderCommandReactor.ts, ProviderRuntimeIngestion.ts, which the V2 merge removed. V2 ingests typed provider events into run and turn-item projections.
Sorry for the extra work this creates. If the change is still needed on V2, please rebuild it on current main, verify it there, and open a new PR linking back here. We're closing the current implementation without assuming the underlying request is resolved.
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed