Skip to content

fix(prompt_agent): a re-run closes the conversations a dead run of the step left active - #937

Open
psinghal20 wants to merge 1 commit into
andrew-park/a2a-conversation-closefrom
pratyush/close-leaked-conversations
Open

psinghal20 wants to merge 1 commit into
andrew-park/a2a-conversation-closefrom
pratyush/close-leaked-conversations

Conversation

@psinghal20

@psinghal20 psinghal20 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #951, which closes a prompt step's conversation however the step ends and reopens it on a re-run with the same conversation id.

A step without context_id mints a new conversation id on every run. When its worker dies mid-step, nothing in that process closes the conversation, and the re-run's reopen never finds it, so it stays active and pending in the hub worklist.

The record now carries the step_id that created it, and the step closes the active conversations an earlier run of it left for the same task instance (close_active_for_step) at the start of _execute, before anything reaches the agent, so a re-run that fails early still closes them. A step with context_id shares its conversation across runs, gets no step_id and is left to #951's reopen. Records written before this have no step_id and are never swept.

Not covered: a worker that dies with no later run of the step, and cancelling the earlier agent turn. An earlier run that is stuck but alive when the step is re-run has its conversation closed, and #951's guard refuses its next turn.

Validation: 3 step tests (re-run closes the leftover, a re-run failing before its own conversation still closes it, context_id not swept), the first two failing with the sweep disabled; 2 store tests; with #951's 11 conversation tests, 16 pass; ruff check clean. The tst/unit/task_step, a2a_agent and store suites pass except 6 failures in computer_exec_test.py and test_mcp_cli_builder.py that also fail on main.

Once #951 lands, this branch is rebased onto main.

🤖 Generated with Claude Code

Confidence Score: 5/5 · The PR appears safe to merge; no new actionable issues remain.RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no new actionable issues remain.

Summary

Adds step_id to conversations owned by prompt_agent and closes active leftovers before a new attempt contacts the agent.

  • A prompt_agent rerun closes active conversations left by the same step.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Start prompt step] --> B{Fixed context_id?}
  B -->|No| C[Close active leftovers for this task instance and step]
  B -->|Yes| D[Keep shared conversation behavior]
  C --> E[Configure agent and start conversation]
  D --> E
Loading

Reviews (3) · Last reviewed commit: "fix(prompt_agent): a re-run closes the c..." · Reviewed by Greptile

@psinghal20
psinghal20 requested a review from a team as a code owner November 27, 2026 15:25
@earakely-scale

Copy link
Copy Markdown
Collaborator

🤖 Automated Claude routine — Env Pod PR Context Review. This is a bot, not Edgar Arakelyan; not a human review.

Context from a newer open PR: #951 (fix(prompt_agent): close the A2A conversation however the step ends) fixes the same leaked-active conversation in PromptAgentTaskStep. It moves the create_conversation(...) call that this PR adds step_id= to (prompt_agent.py:679 here) into a new reopen-then-create block (#951 prompt_agent.py:706-717). If either PR rebases over the other and that hunk loses step_id, close_active_for_step (conversation_store.py:362 here) matches nothing, and no test fails. #951 also closes in a finally, which overlaps this PR's except BaseException → _close_left_open. Details are on #951. You may want to coordinate on which one lands first.


Generated by Claude Code

…e step left active

A step without context_id mints a new conversation id on every run, so when
its worker dies and the step is re-run, the earlier conversation stays active
and reopen never finds it. The record now carries the step_id that created it,
and the step closes the active conversations an earlier run of it left for the
same task instance before anything reaches the agent (close_active_for_step).
A step with context_id shares its conversation across runs and is left to
reopen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@psinghal20
psinghal20 force-pushed the pratyush/close-leaked-conversations branch from 73e19d8 to cbc10d5 Compare November 30, 2026 13:16
@psinghal20
psinghal20 changed the base branch from main to andrew-park/a2a-conversation-close November 30, 2026 13:16
@psinghal20 psinghal20 changed the title fix(task-step): prompt_agent closes the conversation a failed, cancelled or dead run leaves active fix(prompt_agent): a re-run closes the conversations a dead run of the step left active Nov 30, 2026

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants