fix: workflow step losing its completion tool on automatic retry - #48
Merged
Merged
Conversation
Kimchi Code ReviewA review is being prepared and will be posted shortly.
What to expectKimchi will analyze the changes in this pull request and post:
The review typically completes within a few minutes. This comment will be updated once the review is ready. Interact with Kimchi
ConfigurationReviews are configured by your organization admin. Powered by Kimchi — AI-powered code review by CAST AI |
pmateusz
force-pushed
the
fix/step-tools-across-auto-retry
branch
3 times, most recently
from
September 4, 2026 15:52
2eb2d23 to
4eed2a6
Compare
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
force-pushed
the
fix/step-tools-across-auto-retry
branch
from
September 7, 2026 06:43
deb395b to
4da078b
Compare
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.