Skip to content

chore: print more information in concat mode and handle empty tool calls for easy debugging#713

Merged
garrett4wade merged 4 commits intomainfrom
mzy/concat-warn
Dec 11, 2025
Merged

chore: print more information in concat mode and handle empty tool calls for easy debugging#713
garrett4wade merged 4 commits intomainfrom
mzy/concat-warn

Conversation

@nuzant
Copy link
Copy Markdown
Collaborator

@nuzant nuzant commented Dec 11, 2025

Description

This pull request refactors warning logic and improves message similarity reporting in the OpenAI interaction cache and client modules. The main changes include removing global single-warning flags, enhancing the reporting of message differences, and improving handling of empty tool calls.

Warning logic and reporting improvements:

  • Removed global warning flags (MESSAGE_SIMILARITY_WARNED and CONCAT_PROMPT_TOKEN_IDS_WARNED) in both cache.py and client.py, so warnings are now logged every time the condition is met instead of only once. [1] [2]
  • Enhanced the _is_similar_on_last_message function in cache.py to return detailed differences between parent and child messages, improving the warning message with specific key differences. [1] [2]
  • Updated the warning logic in concat_prompt_token_ids_with_parent in client.py to log a warning every time extra fields are present in messages, rather than only once.

Message and output handling improvements:

  • In the create method of client.py, changed handling of tool_calls so that empty lists are converted to None, ensuring proper serialization and downstream handling.

Related Issue

Fixes #(issue)

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not
    work as expected)
  • Documentation update
  • Code refactoring (no functional changes)
  • Performance improvement
  • Test coverage improvement

Checklist

  • I have read the Contributing Guide
  • I have run formatting tools (pre-commit or manual)
  • I have run relevant unit tests and they pass
  • I have added tests for new functionality
  • I have updated documentation if needed
  • My branch is up to date with main
  • This PR introduces breaking changes (if yes, fill out details below)
  • If this PR changes documentation, I have built and previewed it locally with
    jb build docs
  • No critical issues raised by AI reviewers (/gemini review)

Breaking Change Details (if applicable):

Additional Context


Need help? Check the Contributing Guide or ask in
GitHub Discussions!

@nuzant nuzant requested a review from dhh1995 December 11, 2025 10:45
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @nuzant, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the debugging experience and robustness of OpenAI interaction handling. It refactors warning mechanisms to provide more frequent and detailed feedback on message similarity issues and prompt concatenation, while also standardizing the representation of empty tool calls to prevent serialization problems. These changes aim to make it easier to identify and resolve issues related to conversation tree building and API interactions.

Highlights

  • Warning Logic Refinement: Global warning flags (MESSAGE_SIMILARITY_WARNED, CONCAT_PROMPT_TOKEN_IDS_WARNED) have been removed from cache.py and client.py, ensuring that relevant warnings are logged every time their conditions are met, rather than only once.
  • Enhanced Message Similarity Reporting: The _is_similar_on_last_message function in cache.py now returns specific key differences between messages, which are then incorporated into the warning logs for more detailed debugging information.
  • Improved Tool Call Handling: In client.py, the create method now converts empty tool_calls lists to None, standardizing their representation for proper serialization and downstream processing.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request improves logging and debugging capabilities by removing one-time warning flags and providing more detailed information in warnings. The changes in cache.py to report differences in similar messages and in client.py to handle empty tool_calls are good enhancements. I've identified a few areas for improvement: an incorrect type hint, an opportunity for a more detailed warning message, and a typo in a comment. Overall, these are solid improvements.

Comment thread areal/experimental/openai/cache.py
Comment thread areal/experimental/openai/client.py
Copy link
Copy Markdown
Collaborator

@garrett4wade garrett4wade left a comment

Choose a reason for hiding this comment

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

LGTM

@nuzant
Copy link
Copy Markdown
Collaborator Author

nuzant commented Dec 11, 2025

All related tests in areal/tests/experimental/openai/test_*.py have passed.
image

@garrett4wade garrett4wade merged commit a3cb4e0 into main Dec 11, 2025
1 check passed
@garrett4wade garrett4wade deleted the mzy/concat-warn branch December 11, 2025 11:29
garrett4wade pushed a commit that referenced this pull request Dec 11, 2025
leandermaben pushed a commit to leandermaben/AReaL that referenced this pull request Mar 24, 2026
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