Skip to content

fix: remove SOFT_LIMIT_REACHED logic, tool compression, and fix bugs#414

Merged
luispater merged 2 commits intorouter-for-me:mainfrom
CheesesNguyen:fix/remove-soft-limit-and-tool-compression
Mar 5, 2026
Merged

fix: remove SOFT_LIMIT_REACHED logic, tool compression, and fix bugs#414
luispater merged 2 commits intorouter-for-me:mainfrom
CheesesNguyen:fix/remove-soft-limit-and-tool-compression

Conversation

@CheesesNguyen
Copy link

  • 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
@gemini-code-assist
Copy link

Summary of Changes

Hello, 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 SOFT_LIMIT_REACHED mechanism and dynamic tool compression. These changes aim to streamline the process of managing tool outputs and inputs, potentially simplifying the interaction with underlying models. Additionally, several specific bugs related to tool output formatting and ID assignment have been addressed, alongside minor code cleanup and .gitignore updates, contributing to overall system stability and maintainability.

Highlights

  • Removal of SOFT_LIMIT_REACHED Logic: The complex logic for injecting and detecting SOFT_LIMIT_REACHED markers in the response and request paths, as well as streaming, has been entirely removed. This simplifies the tool handling mechanism and removes a potentially confusing behavior for truncated tool outputs.
  • Elimination of Tool Compression: The dynamic tool compression functionality, including the tool_compression.go file and related constants, has been removed. This indicates that the previous approach to handle large tool payloads is no longer necessary or desired.
  • Bug Fix: Truncation Detector Output: A bug in the truncation_detector was fixed where string(rune(len)) incorrectly produced a Unicode character instead of a decimal string for the byte count in truncation error messages.
  • Bug Fix: WebSearchToolUseId Overwrite: The WebSearchToolUseId was being incorrectly overwritten by non-web-search tools. This has been corrected to ensure it only captures IDs for web_search or remote_web_search tools.
  • Cleanup: Duplicate Model Entry: A duplicate 'kiro' entry in the model_definitions.go comment section was removed, improving code clarity.
  • Build Output Ignored: New entries for build output files (CLIProxyAPIPlus, CLIProxyAPIPlus.app/) were added to .gitignore to prevent them from being committed to the repository.

🧠 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
  • .gitignore
    • Added entries for CLIProxyAPIPlus and CLIProxyAPIPlus.app/ to ignore build output.
  • internal/registry/model_definitions.go
    • Removed a duplicate 'kiro' entry from the model definitions comment.
  • internal/runtime/executor/kiro_executor.go
    • Removed the hasTruncatedTools variable.
    • Eliminated the logic for emitting SOFT_LIMIT_REACHED markers for truncated tools.
    • Removed the special handling for SOFT_LIMIT_REACHED in determining the stop reason.
  • internal/translator/kiro/claude/kiro_claude_request.go
    • Removed the compressToolsIfNeeded function call, effectively disabling dynamic tool compression.
    • Removed the logic that detected SOFT_LIMIT_REACHED in tool results and replaced error content with guidance.
  • internal/translator/kiro/claude/kiro_claude_response.go
    • Removed the logic for emitting SOFT_LIMIT_REACHED marker inputs for truncated tools.
    • Modified tool handling to simply skip truncated tools and log a warning instead of injecting a marker.
  • internal/translator/kiro/claude/kiro_claude_stream_parser.go
    • Updated the logic to capture WebSearchToolUseId only when the tool name is 'web_search' or 'remote_web_search', preventing overwrites by other tools.
  • internal/translator/kiro/claude/tool_compression.go
    • Removed the entire file, eliminating the tool compression functionality.
  • internal/translator/kiro/common/constants.go
    • Removed ToolCompressionTargetSize and MinToolDescriptionLength constants, which were related to the removed tool compression feature.
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

@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 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)

security-medium medium

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)

security-medium medium

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)

medium

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.
@luispater luispater merged commit 13c93e8 into router-for-me:main Mar 5, 2026
1 of 2 checks passed
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