fix(agents): recover real tool calls from fabricated observation continuations - #6758
Draft
HUAN2022A wants to merge 1 commit into
Draft
Conversation
…inuations Models that ignore stop sequences can generate past the real Action/Action Input and fabricate an Observation plus Final Answer in a single completion. process_llm_response had a dead recovery block for this since crewAIInc#2483 removed the parser error it relied on, so the fabricated Final Answer won and the real tool call was never executed. Replace the dead exception path with an explicit shape check: when stop words are unsupported and a Final Answer follows a parsed Action, drop everything from that Final Answer onward so the real Action is executed. Adds regression tests for the fabrication shape, the stop-word path, Observation: text inside action input payloads, and genuine final answers.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
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.
Summary
process_llm_responsehad a dead recovery block, so when a model that does not support stop words fabricated anObservation:+Final Answer:continuation after a realAction, the fabricated answer won and the real tool call was never executed. This PR replaces the dead exception path with an explicit shape check: when stop words are unsupported and aFinal Answer:follows a parsedAction, everything from thatFinal Answer:onward is dropped so the real action executes.Related: #3154, #6449.
Note: the issue author's PR #6450 is stale and unmerged; this is an independent implementation with a slightly different truncation strategy.
Validation
origin/maintest_agent_utils.py: 78/78 passed, including 5 new regression testsruffclean on changed files