Skip to content

single string tool response should just be string#81

Merged
benjibc merged 1 commit intomainfrom
tool_response_single_string
Aug 14, 2025
Merged

single string tool response should just be string#81
benjibc merged 1 commit intomainfrom
tool_response_single_string

Conversation

@benjibc
Copy link
Copy Markdown
Contributor

@benjibc benjibc commented Aug 14, 2025

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors how tool response content is formatted in the Agent class to optimize for OpenAI API semantics, where single text responses can be represented as plain strings rather than arrays.

  • Extracts tool content formatting logic into a dedicated _format_tool_message_content method
  • Returns plain strings for single text responses instead of always using arrays
  • Maintains backwards compatibility by still returning arrays for multiple text items

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
eval_protocol/pytest/default_agent_rollout_processor.py Refactors tool message content formatting by extracting logic into a new method and optimizing single text responses
tests/pytest/test_tool_response_single_string.py Adds comprehensive test coverage for the new tool content formatting behavior

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


def _format_tool_message_content(
self, content: List[TextContent]
) -> Union[str, List[ChatCompletionContentPartTextParam]]:
Copy link

Copilot AI Aug 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return type annotation is missing the import for Union. Add 'from typing import Union' to the imports.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

@benjibc benjibc merged commit 4491f56 into main Aug 14, 2025
7 checks passed
@benjibc benjibc deleted the tool_response_single_string branch August 14, 2025 18:12
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.

2 participants