bug(antigravity/claude): parse <thinking> XML tags into thought blocks#1867
bug(antigravity/claude): parse <thinking> XML tags into thought blocks#1867lang-911 wants to merge 10 commits intorouter-for-me:mainfrom
Conversation
Summary of ChangesHello, 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 addresses a bug where Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new parser for <thinking> tags in Antigravity Claude responses, which is a great feature. The implementation is solid, with comprehensive tests covering various scenarios, including streaming and split tags. I've identified a critical issue related to double-processing of payloads which should be addressed. Additionally, I have a couple of suggestions for the new thinking_tag_parser.go file to improve maintainability and robustness. Overall, good work on this feature.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a robust ThinkingTagParser to correctly parse <thinking> XML tags within streaming responses from Claude models. The implementation effectively handles partial tags across stream chunks, which is crucial for streaming data processing. The new thinking_tag_parser.go file is well-structured, and its integration into antigravity_executor.go is clean and appropriate. The accompanying test suite (thinking_tag_parser_test.go) is comprehensive, covering a wide range of scenarios, including edge cases like split tags, empty blocks, and unicode-escaped tags, which significantly enhances the reliability of this new feature. Overall, this is a well-engineered and thoroughly tested addition.
JasperDale420
left a comment
There was a problem hiding this comment.
Not merging this yet. The existing review on the PR already flags a critical double-processing risk in the new thinking-tag path, and I do not want to ship the executor changes until that issue is resolved and the branch is re-reviewed.
luispater
left a comment
There was a problem hiding this comment.
Thanks — the latest commit fixes the earlier double-processing concern, and the parser coverage is strong. I still see one blocking issue in the split path: when a single text part is split into multiple segments, the parser rebuilds fresh part objects with only text/thought and drops original metadata. That is risky for Claude because the downstream Antigravity->Claude response translator relies on thoughtSignature to cache/replay signed thinking blocks in later turns. If a tagged text part also carries thoughtSignature, the current rewrite loses it before translation. Please preserve relevant metadata on the resulting thought segment(s) — at minimum thoughtSignature — and add a regression test for a tagged text part that also includes a signature.
Closes router-for-me#1777 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove double thinkingParser processing from convertStreamToNonStream - Generate partial tag lists programmatically via generatePartials() - Handle sjson.Set errors with logging instead of silent discard Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
54ad2e8 to
d373d79
Compare
|
Updated in d373d79. Addressed the latest blocking review by preserving thought signatures when tag parsing rewrites a text part:
Added regressions for the split tagged-part case, the single-segment case, the close-tag-only case, and a Claude translator contract test for signature caching. Validation:
|
|
Follow-up in 0a83ee0: the failed translator-path-guard check was caused by my earlier regression test addition under internal/translator, not by the parser fix itself. I moved that contract coverage into internal/runtime/executor/thinking_tag_parser_test.go and restored internal/translator/antigravity/claude/antigravity_claude_response_test.go to its original content so the PR no longer changes restricted translator paths. Revalidated:
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a robust parser for <thinking> XML tags in Antigravity Claude responses, correctly handling streaming and chunked data. The new ThinkingTagParser is stateful and manages partial tags across stream chunks effectively. The integration into the AntigravityExecutor for both streaming and non-streaming paths is well-implemented. The addition of a comprehensive test suite provides strong validation for the new functionality. My review includes a few minor suggestions to improve code clarity and conciseness by removing redundant code and simplifying some return statements.
|
Addressed the latest gemini-code-assist cleanup findings in
Validation:
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a ThinkingTagParser to handle <thinking> tags in responses from Antigravity Claude models. The parser is stateful to correctly process streaming responses where tags might be split across multiple chunks. The implementation is robust, with comprehensive unit tests covering various edge cases.
My review focuses on the new parser implementation. I've identified opportunities to improve performance and readability in two helper functions by reducing redundant JSON processing. The core parsing logic appears sound and well-tested.
|
Addressed the remaining gemini-code-assist findings in
Validation:
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a robust parser for <thinking> tags in Antigravity Claude responses, correctly handling streaming and non-streaming scenarios. The implementation is well-structured and includes a comprehensive test suite that covers numerous edge cases. The integration into the existing executor is clean. I have one suggestion to simplify a helper function for better readability and minor performance improvement.
|
Addressed the latest gemini-code-assist helper cleanup in
Validation:
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a robust parser for <thinking> tags in Antigravity Claude model responses, handling streaming and partial tags effectively. The implementation is well-structured and accompanied by a comprehensive set of unit tests that cover numerous edge cases, which is great to see. I have one suggestion to improve the performance and consistency of JSON manipulation in the new parser.
|
Addressed the final gemini-code-assist finding in
Validation:
All Gemini review threads on this PR are now resolved. /gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a parser for <thinking> tags in Antigravity Claude responses, which is a great enhancement for handling model thoughts. The implementation includes a new stateful ThinkingTagParser that correctly processes streaming data, including tags split across multiple chunks. The logic is applied to both streaming and stream-to-non-stream execution paths in the Antigravity executor. The addition of a comprehensive test suite covering numerous edge cases is excellent and provides high confidence in the correctness of the new parser. The code is well-structured. I have one minor suggestion to improve code idiom.
|
Addressed the final gemini-code-assist readability suggestion in
Validation:
|
|
Thank you for the diligent updates, |
Closes #1777
Summary
<thinking>...</thinking>text blocksValidation