fix: remove SOFT_LIMIT_REACHED logic, tool compression, and fix bugs#414
Conversation
CheesesNguyen
commented
Mar 5, 2026
- Remove SOFT_LIMIT_REACHED marker injection in response path
- Remove SOFT_LIMIT_REACHED detection logic in request path
- Remove SOFT_LIMIT_REACHED streaming logic in executor
- Remove tool_compression.go and related constants
- Fix truncation_detector: string(rune(len)) producing Unicode char instead of decimal string
- Fix WebSearchToolUseId being overwritten by non-web-search tools
- Fix duplicate kiro entry in model_definitions.go comment
- Add build output to .gitignore
- Remove SOFT_LIMIT_REACHED marker injection in response path - Remove SOFT_LIMIT_REACHED detection logic in request path - Remove SOFT_LIMIT_REACHED streaming logic in executor - Remove tool_compression.go and related constants - Fix truncation_detector: string(rune(len)) producing Unicode char instead of decimal string - Fix WebSearchToolUseId being overwritten by non-web-search tools - Fix duplicate kiro entry in model_definitions.go comment - Add build output to .gitignore
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 significantly refactors the tool handling within the system by removing the 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
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 simplifies the codebase by removing the SOFT_LIMIT_REACHED logic and associated tool compression functionality, aiming for easier maintenance. However, a security audit identified two medium-severity issues: a logic flaw in the streaming executor that can lead to incorrect turn termination signals when tools are truncated, and a potential resource exhaustion risk due to the removal of tool definition compression. These issues could impact the reliability and state consistency of automated agents using the proxy. Additionally, the PR addresses several bugs, including a string conversion issue in the truncation_detector and a problem with WebSearchToolUseId being overwritten.
I am having trouble creating individual review comments. Click here to see my feedback.
internal/runtime/executor/kiro_executor.go (3289-3292)
The modified logic for handling truncated tools in streamToChannel simply skips the tool use and continues the loop. This is problematic because it fails to close any currently open text blocks (isTextBlockOpen) and fails to set the hasToolUses flag. Consequently, if a tool is truncated, the proxy may send an incorrect stop_reason of "end_turn" instead of "tool_use" to the client. This can cause automated agents (like Claude Code) to misinterpret a failed tool call as a completed turn, potentially leading to unintended actions or state corruption in the agent's environment.
internal/translator/kiro/claude/kiro_claude_request.go (608-610)
The removal of the compressToolsIfNeeded function call removes a safeguard against excessively large tool definitions. This can lead to resource exhaustion (DoS) when processing requests with many tools or very large tool schemas, potentially causing 500 errors from the upstream API or high memory consumption on the proxy.
internal/translator/kiro/claude/truncation_detector.go (345)
While formatInt correctly converts the integer to a string, using strconv.Itoa from the standard library would be more idiomatic and efficient. The custom formatInt implementation involves repeated string concatenation, which can be inefficient. Is there a strong reason to avoid importing the strconv package? If not, I'd recommend using strconv.Itoa and removing the custom formatInt function. You'll need to add "strconv" to the imports.
sb.WriteString(strconv.Itoa(len(rawInput)))
… fields Tools like TaskList, TaskGet have no required parameters, so empty input is valid. Previously, the truncation detector flagged all empty inputs as truncated, causing these tools to be skipped and breaking the tool loop. Now only flag empty input as truncation when the tool has required fields defined in RequiredFieldsByTool.