Bugfix: Web surfer creating incomplete copy of messages #4050
+2
−2
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.
Why are these changes needed?
Previously,
generate_surfer_reply
would create not a full copy of messages, it would not include the last one. This is behaviour would result inopenai.BadRequestError
exception, if the last message was a tool message.The openAI client expects that for each assistant message with tool_call, a tool message with corresponding tool_call_id has to exist in passed messages. In the edge case where tool call response was the last message in history, web surfer agent was excluding it, which lead to showcased exception.
Once the slice operates on entire list, the issue disappears.
Related issue number
N/A
Checks