Skip to content

fix(runner): finish stopped turns before running steered input - #6592

Merged
mmabrouk merged 1 commit into
release/v0.115.2from
fix/release-1152-steer-settlement
Sep 6, 2026
Merged

fix(runner): finish stopped turns before running steered input#6592
mmabrouk merged 1 commit into
release/v0.115.2from
fix/release-1152-steer-settlement

Conversation

@mmabrouk

@mmabrouk mmabrouk commented Sep 5, 2026

Copy link
Copy Markdown
Member

Context

Steer could cancel a running tool and then lose the follow-up with “This session is already running a turn.” The runner reported Stop completion immediately after issuing the abort, allowing the API to promote the saved input while the original environment was still busy.

Changes

Keep the immediate HTTP acknowledgement, but report the stopped outcome after the execution finishes teardown and releases ownership. Duplicate deliveries wait for that same outcome. An abandoned execution reports failure rather than allowing Steer to enter an environment that may still be busy.

Tests

  • Reproduced with a real running shell: cancellation succeeded, but the promoted input failed before the original turn ended.
  • Repeated that exact sequence with the fix: correct execution cancelled, follow-up started after its predecessor ended, one saved agent reply, no error records, empty queue and idle session.
  • Control/server/timeout regressions: 91 passed, including immediate abort, delayed outcome, duplicate delivery, abandonment, abort failure and execution identity.
  • Full runner suite initially passed 2,902 tests; four failures needed generated tool-shim assets, and an existing pause-teardown test needed to release its mocked teardown before awaiting the final outcome. Both affected suites then passed all 91 tests. Strict typecheck passed.

What to QA

Start a long shell operation, use Steer while the tool is running, and verify the original stops and the follow-up runs once. Check ordinary Stop still acknowledges immediately and keeps the next message usable.

Stacked on #6591 for release/v0.115.2.

@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
agenta-documentation Ready Ready Preview Sep 5, 2026 11:46pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Team

Run ID: ff971e9b-9291-4766-998c-05d652de5728

📥 Commits

Reviewing files that changed from the base of the PR and between a6f2795 and 20cd767.

📒 Files selected for processing (6)
  • services/runner/src/server.ts
  • services/runner/src/sessions/applied-commands.ts
  • services/runner/src/sessions/control-channel.ts
  • services/runner/src/sessions/execution-registry.ts
  • services/runner/tests/unit/control-command-apply.test.ts
  • services/runner/tests/unit/sandbox-agent-orchestration.test.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Stop requests now wait for the active run to finish releasing resources before reporting the final outcome.
    • Duplicate stop requests remain synchronized with the original request and receive the correct final status.
    • Abandoned runs now report a failed outcome instead of leaving requests unresolved.
    • Stop handling remains reliable even when cleanup encounters an error or when a newer run starts.

Walkthrough

The runner now tracks teardown completion, exposes per-execution release signals, and delays Stop outcomes until teardown settles. Duplicate commands await the original command. Tests cover normal, abandoned, failed-abort, and successor-execution cases.

Changes

Stop teardown settlement

Layer / File(s) Summary
Execution release tracking
services/runner/src/sessions/applied-commands.ts, services/runner/src/sessions/execution-registry.ts
Commands now expose settlement promises. The execution registry resolves per-run release signals during unregistration and test reset.
Command settlement after teardown
services/runner/src/sessions/control-channel.ts, services/runner/tests/unit/control-command-apply.test.ts
Stop handling waits for environment release before reporting. Duplicate, abandoned, abort-failure, and successor-execution cases are covered.
Runner teardown status integration
services/runner/src/server.ts, services/runner/tests/unit/sandbox-agent-orchestration.test.ts
The streaming runner passes teardown completion to unregistration. Orchestration tests await the Stop outcome after unregistration.

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

Merge Risk: ⚪ Minimal · up to 20cd7

Stop outcomes now wait for execution teardown and ownership release, preventing follow-up input from starting against a busy environment. Covered cancellation and duplicate-delivery paths show no remaining merge-blocking risk.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ControlChannel
  participant ExecutionRegistry
  participant Runner
  Client->>ControlChannel: applyCommand(Stop)
  ControlChannel->>Runner: abort()
  Runner->>ExecutionRegistry: unregisterExecution(..., teardownCompleted)
  ExecutionRegistry-->>ControlChannel: release status
  ControlChannel-->>Client: settled outcome
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 60.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 6 files.
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 main change: completing stopped turns before processing steered input.
Description check ✅ Passed The description directly explains the teardown ordering fix, duplicate synchronization, abandonment behavior, tests, and QA steps.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/release-1152-steer-settlement

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.

@mmabrouk

mmabrouk commented Sep 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

Please review the execution-release fence, duplicate outcome ordering, and abandonment safety. The live running-Steer regression now passes; the original reproduced failure and targeted runner regressions guided this change.

Requested by Codex (OpenAI), acting for Mahmoud.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@mmabrouk I will perform a full review of #6592. I will focus on execution-release ordering, duplicate outcome synchronization, abandonment handling, and the stated runner regressions.

✅ Action performed

Full review finished.

@mmabrouk mmabrouk changed the title [fix] Finish stopped turns before running steered input fix(runner): finish stopped turns before running steered input Sep 5, 2026
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Status Destroyed (PR closed)

Updated at 2026-09-06T02:47:22.481Z

@mmabrouk
mmabrouk changed the base branch from fix/release-1152-session-reader to release/v0.115.2 September 6, 2026 02:46
@mmabrouk
mmabrouk merged commit 9176071 into release/v0.115.2 Sep 6, 2026
65 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant