Skip to content

fix: release conversation subject in cancel terminal update - #490

Open
onatozmenn wants to merge 2 commits into
OpenHands:mainfrom
onatozmenn:fix/release-subject-on-cancel
Open

onatozmenn wants to merge 2 commits into
OpenHands:mainfrom
onatozmenn:fix/release-subject-on-cancel

Conversation

@onatozmenn

@onatozmenn onatozmenn commented Sep 18, 2026

Copy link
Copy Markdown

HUMAN:

I ran the targeted pytest suite and confirmed all 109 tests pass, including the two new subject-release cases that fail on base and pass with the fix, with ruff checks also clean.


Why

Cancelling a run that holds a conversation subject only released it when the run had recorded a sandbox_id (and in a second write after the terminal update). Local-mode and conversation-turn child runs often have no sandbox_id, so subject_released_at stayed unset and a resubmitted subject kept deduplicating against the cancelled run instead of creating a replacement (#472).

Summary

  • Record subject_released_at atomically in the cancel terminal UPDATE (conditional on subject_key), independent of sandbox_id.
  • Drop the now-redundant post-update release; sandbox cleanup path unchanged.
  • Add regression tests: subject run without sandbox releases, ordinary runs untouched, cancelled subject routes resubmission to a new run via continue_conversation.

Issue Number

Fixes #472

How to Test

python -m pytest tests/test_cancel_run.py tests/test_conversations.py tests/test_watchdog.py -q — 109 passed. The two new subject tests fail on base and pass with the fix. ruff check / ruff format --check clean.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions github-actions Bot added the type: fix A bug fix label Sep 18, 2026
@onatozmenn
onatozmenn marked this pull request as ready for review September 18, 2026 13:32
Copilot AI lite review requested due to automatic review settings September 18, 2026 13:32
@all-hands-bot

Copy link
Copy Markdown
Contributor

👋 This PR needs a couple of things fixed before OpenHands can review it:

  • the PR description's HUMAN: section needs at least 20 characters describing what you tested, not just the template placeholder

Push an update once this is addressed and this check re-runs automatically.

This is an automated check - no AI was used to generate this comment.

1 similar comment
@all-hands-bot

Copy link
Copy Markdown
Contributor

👋 This PR needs a couple of things fixed before OpenHands can review it:

  • the PR description's HUMAN: section needs at least 20 characters describing what you tested, not just the template placeholder

Push an update once this is addressed and this check re-runs automatically.

This is an automated check - no AI was used to generate this comment.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The regression test does not exercise an actual resubmission after cancellation.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This pull request fixes cancellation so conversation subjects are released atomically, including runs without sandboxes.

Changes:

  • Updates cancellation to set subject_released_at.
  • Removes redundant post-update release logic.
  • Adds cancellation regression tests.
File summaries
File Description
tests/test_cancel_run.py Tests subject release and ordinary cancellations.
openhands/automation/router.py Atomically releases subjects during cancellation.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/test_cancel_run.py Outdated
Comment on lines +170 to +174
async def test_cancelled_subject_no_longer_blocks_resubmission(
async_client, async_session
):
"""After cancel, no unreleased run holds the subject, so a resubmission
routes to a new run instead of deduplicating against the cancelled one."""
Co-authored-by: openhands <openhands@all-hands.dev>
@onatozmenn

Copy link
Copy Markdown
Author

Good catch — the resubmission test now goes through the real routing path: it cancels a queued subject run, then calls continue_conversation for the same subject and asserts needs_run is True. On base this fails (the turn gets coalesced into the dead run, so no replacement run is ever created); with the fix it passes.

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

Labels

type: fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Release conversation subjects when runs are cancelled

3 participants