Skip to content

Port the surgical toolResult stripping from buyer-agent - #36

Open
aleksUIX wants to merge 1 commit into
IABTechLab:mainfrom
aleksUIX:fix/port-surgical-toolresult-strip
Open

Port the surgical toolResult stripping from buyer-agent#36
aleksUIX wants to merge 1 commit into
IABTechLab:mainfrom
aleksUIX:fix/port-surgical-toolresult-strip

Conversation

@aleksUIX

Copy link
Copy Markdown
Contributor

Problem

patches/crewai_bedrock_fix.py has drifted between buyer-agent and seller-agent, and each repo is missing the other's fix. The one seller-agent lacks: buyer's surgical toolResult stripping. When a user message carries toolResult blocks and at least one has no matching toolUse in the preceding assistant message, the seller copy strips ALL toolResult blocks and keeps only text. Valid tool results are discarded along with the orphans, so the model loses tool output it legitimately produced.

Change

Ports buyer-agent's surgical version: only toolResult blocks whose toolUseId is absent from the preceding assistant message's toolUse set are stripped; matched toolResults and text blocks are kept. The file is now byte-identical with the buyer-agent copy, at the union of both repos' fixes; a matching PR to buyer-agent ports seller's _patch_parse_native_tool_call in the other direction, so the two copies stay in sync. One docstring bullet updated to match the behavior.

Verification

Ran against installed crewai: patches apply cleanly, and for a user message carrying one matched and one orphaned toolResult, the sanitizer now keeps the matched block and the text block while stripping only the orphan (previously both toolResults were dropped).

patches/crewai_bedrock_fix.py has drifted between the two agent repos.
buyer-agent's sanitizer strips only the toolResult blocks whose
toolUseId has no matching toolUse in the preceding assistant message;
the seller copy stripped ALL toolResult blocks in that case, discarding
valid tool results along with the orphans and losing tool output from
the conversation.

This ports buyer's surgical version and brings the file to the union of
both repos' fixes, byte-identical with the buyer-agent copy (a matching
PR ports _patch_parse_native_tool_call there). Also documents the
surgical-strip behavior in the sanitizer docstring.
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