← Back to PRs

#11274: fix(tools): truncate overly long tool names for API compatibility

by avirweb open 2026-02-07 16:59 View on GitHub →
agents stale
## Summary - Truncate tool names to stay within provider/API limits and avoid runtime failures. - Keep tool-name handling behavior consistent across policy/adapter paths. - AI-Assisted: Yes (built with Claude/OpenCode) ## Testing - Verified branch diff against `upstream/main` is non-zero. - Verified branch head SHA matches expected prepared commit. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This change introduces `truncateToolNameForOpenAI()` in `src/agents/tool-policy.ts` and applies it in `src/agents/pi-tool-definition-adapter.ts` so tool/function names sent to the provider stay within a 64-character limit. The main integration concern is that truncation changes the external identifier (`ToolDefinition.name`) while other parts of the tool-call flow (hooks, client delegation callback, and JSON result payloads) continue to reference the original/untruncated name. If any layer expects a single canonical identifier for dispatch/policy/telemetry, truncation can cause tool calls to fail or be mis-attributed when names exceed the limit. <h3>Confidence Score: 3/5</h3> - This PR is directionally correct but may break tool-call name consistency when truncation occurs. - Truncating the provider-facing tool name addresses API limits, but the implementation currently introduces two tool identifiers in the same execution path (truncated vs original). If downstream dispatch/policy or client delegation relies on exact name matching, tool calls with long names can fail or be inconsistently handled. Otherwise, changes are small and localized. - src/agents/pi-tool-definition-adapter.ts <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment -->

Most Similar PRs