[PR #223] [MERGED] Fix Kiro provider 500 error by enforcing per-tool description length limit #305

Closed
opened 2026-02-27 07:18:53 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/justlovemaki/AIClient-2-API/pull/223
Author: @tickernelz
Created: 1/13/2026
Status: Merged
Merged: 1/13/2026
Merged by: @justlovemaki

Base: mainHead: fix/kiro-tool-filtering


📝 Commits (2)

  • f18ce00 refactor(kiro): simplify tool size compression logic
  • ffb1cfe refactor(kiro): remove schema simplification and size-based compression

📊 Changes

1 file changed (+23 additions, -65 deletions)

View changed files

📝 src/providers/claude/claude-kiro.js (+23 -65)

📄 Description

Problem

Claude provider returns 500 error when sending requests to Kiro API, while OpenCode provider works normally.

Root Cause

Kiro API has a hard limit of 10,240 characters per tool description. The issue was caused by individual tool descriptions exceeding this limit, not by the total number of tools or total payload size.

Analysis showed:

  • Claude Bash tool description: 10,322 characters (exceeds limit)
  • Kiro API returns 500 error when any single tool description > 10,240 chars
  • Multiple tools with descriptions under the limit work fine (tested with 10 tools x 10,000 chars each)

Solution

Implemented per-tool description truncation with a safe limit of 9,216 characters (90% of maximum):

  • Only truncates tools that exceed the limit
  • Preserves full descriptions for tools under the limit
  • Maintains complete schema information (no simplification needed)
  • Adds clear logging for debugging

Changes

  • Modified src/providers/claude/claude-kiro.js to enforce MAX_DESCRIPTION_LENGTH per tool
  • Removed unnecessary schema simplification logic (schemas are only 21% of payload size vs 79% for descriptions)
  • Simplified implementation from 70+ lines to 30 lines of clean code

Testing

Binary search testing confirmed the exact threshold:

  • 10,240 chars: SUCCESS
  • 10,241 chars: FAILED (500 error)
  • 9,216 chars: SUCCESS (recommended with safety margin)

Impact

  • Fixes 500 errors for Claude provider with Kiro API
  • Preserves full tool schema information for accurate model behavior
  • Simple and maintainable solution

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/justlovemaki/AIClient-2-API/pull/223 **Author:** [@tickernelz](https://github.com/tickernelz) **Created:** 1/13/2026 **Status:** ✅ Merged **Merged:** 1/13/2026 **Merged by:** [@justlovemaki](https://github.com/justlovemaki) **Base:** `main` ← **Head:** `fix/kiro-tool-filtering` --- ### 📝 Commits (2) - [`f18ce00`](https://github.com/justlovemaki/AIClient-2-API/commit/f18ce0022e96954b8d8fd1a01354b2990b95d041) refactor(kiro): simplify tool size compression logic - [`ffb1cfe`](https://github.com/justlovemaki/AIClient-2-API/commit/ffb1cfe22d995f428a08a6865c0670316af66750) refactor(kiro): remove schema simplification and size-based compression ### 📊 Changes **1 file changed** (+23 additions, -65 deletions) <details> <summary>View changed files</summary> 📝 `src/providers/claude/claude-kiro.js` (+23 -65) </details> ### 📄 Description ## Problem Claude provider returns 500 error when sending requests to Kiro API, while OpenCode provider works normally. ## Root Cause Kiro API has a hard limit of 10,240 characters per tool description. The issue was caused by individual tool descriptions exceeding this limit, not by the total number of tools or total payload size. Analysis showed: - Claude Bash tool description: 10,322 characters (exceeds limit) - Kiro API returns 500 error when any single tool description > 10,240 chars - Multiple tools with descriptions under the limit work fine (tested with 10 tools x 10,000 chars each) ## Solution Implemented per-tool description truncation with a safe limit of 9,216 characters (90% of maximum): - Only truncates tools that exceed the limit - Preserves full descriptions for tools under the limit - Maintains complete schema information (no simplification needed) - Adds clear logging for debugging ## Changes - Modified src/providers/claude/claude-kiro.js to enforce MAX_DESCRIPTION_LENGTH per tool - Removed unnecessary schema simplification logic (schemas are only 21% of payload size vs 79% for descriptions) - Simplified implementation from 70+ lines to 30 lines of clean code ## Testing Binary search testing confirmed the exact threshold: - 10,240 chars: SUCCESS - 10,241 chars: FAILED (500 error) - 9,216 chars: SUCCESS (recommended with safety margin) ## Impact - Fixes 500 errors for Claude provider with Kiro API - Preserves full tool schema information for accurate model behavior - Simple and maintainable solution --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 07:18:53 +03:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/AIClient-2-API-justlovemaki#305
No description provided.