Skip to content

fix: workflow step losing its completion tool on automatic retry - #48

Merged
pmateusz merged 5 commits into
masterfrom
fix/step-tools-across-auto-retry
Sep 7, 2026
Merged

pmateusz merged 5 commits into
masterfrom
fix/step-tools-across-auto-retry

Conversation

@pmateusz

@pmateusz pmateusz commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

The in-session bridge resolved a turn on agent_end, which PI also fires for a failed attempt that is about to be retried automatically. The engine then condemned the step and dispose() restored the baseline tools, stripping workflow_submit_result while the retried request was still streaming, so the model could no longer submit its result.

agent_end now only records the attempt's messages; the turn resolves on agent_settled, which PI fires only after no automatic retry, compaction, or queued continuation will run. A turn settling without its own agent_end gets empty messages rather than a previous turn's conversation, preserving the cross-talk guard.

@kimchi-review

kimchi-review Bot commented Sep 4, 2026

Copy link
Copy Markdown

Kimchi Code Review

A review is being prepared and will be posted shortly.

Property Value
Commit bdbad9d
Author @pmateusz
Files changed 5
Review status Pending
What to expect

Kimchi will analyze the changes in this pull request and post:

  • A summary of the overall changes
  • Inline comments on specific lines with findings categorized by issue type

The review typically completes within a few minutes. This comment will be updated once the review is ready.

Interact with Kimchi
  • @getkimchi review — re-trigger a full review on the latest commit
  • @getkimchi summary — regenerate the PR summary
  • @getkimchi ignore — skip this PR (no review will be posted)
  • Reply to any inline comment to ask follow-up questions or request clarification
Configuration

Reviews are configured by your organization admin.
Review instructions, excluded directories, and severity thresholds can be adjusted per repository in the Kimchi dashboard.


Powered by Kimchi — AI-powered code review by CAST AI

@pmateusz
pmateusz force-pushed the fix/step-tools-across-auto-retry branch 3 times, most recently from 2eb2d23 to 4eed2a6 Compare September 4, 2026 15:52
pmateusz and others added 2 commits September 7, 2026 08:42
PI fires agent_end when an agent loop ends, including a failed attempt
that an automatic retry is about to continue. The in-session bridge
resolved the turn there, so a retryable transport failure condemned the
step: the engine tore the session down and dispose() restored the
baseline tool set, stripping workflow_submit_result while the retried
request was still streaming and leaving the model no way to submit.

agent_end now only records the attempt's messages, stamped with the
in-flight turn's token; the turn resolves on agent_settled, which PI
fires only after no automatic retry, compaction, or queued continuation
will run. A turn whose run settles without its own agent_end resolves
with empty messages rather than a previous turn's conversation,
preserving the cross-talk guard. Add a regression test scripting the
failed attempt, the retry, and the settle, and extend the existing PI
fakes to emit agent_settled in the real lifecycle order.

Co-Authored-By: Kimchi <noreply@kimchi.dev>
… retries

PI's automatic retry loops emit agent_end/agent_start cycles that the
bridge treated as opaque turns — only the last loop's messages survived,
and nothing detected when the interrupt key cancelled retry backoff.

Accumulate messages per-turn and per-session instead of overwriting a
shared lastConversation, listen for the configured interrupt key between
a failed loop and its continuation, and reset cancellation state on each
new turn so a prior abort doesn't leak into the next one.

Co-Authored-By: Kimchi <noreply@kimchi.dev>
@pmateusz
pmateusz force-pushed the fix/step-tools-across-auto-retry branch from deb395b to 4da078b Compare September 7, 2026 06:43
pmateusz and others added 3 commits September 7, 2026 15:36
…retries

Step output tools returned void details and the bridge reconstructed
submissions from accumulated turn messages, so an automatic retry (or a
prompt steered into an already-running loop) could replay a stale
submission or misattribute one to a different attempt.

Stamp every successful submission with a runId/path/attempt identity in the
PI tool result's details, capture the session leaf before enqueueing each
prompt, and recover the newest matching submission from the session branch
after that cursor when the logical run settles.

Co-Authored-By: Kimchi <noreply@kimchi.dev>
@pmateusz
pmateusz merged commit 7a6765c into master Sep 7, 2026
2 checks passed
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.

1 participant