Repository navigation
perf: avoid repeated Claude tool-name lookups - #7447
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughThe Claude-to-OpenAI converter now defers unnamed ChangesTool name resolution
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Refactor Merge Risk: ⚪ Minimal · up to The conversion preserves the documented tool-result naming behavior while avoiding repeated lookups. No actionable merge risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit reads each line, Comment |
…okup Replace the repeated anonymous struct in the Claude-to-chat converter with a local named type, and remove SearchToolNameByToolCallId now that the converter resolves tool names in a single pass and nothing else calls it.
* perf: avoid repeated Claude tool-name lookups * refactor(relaykit): name tool-result backfill type and drop unused lookup Replace the repeated anonymous struct in the Claude-to-chat converter with a local named type, and remove SearchToolNameByToolCallId now that the converter resolves tool names in a single pass and nothing else calls it.
* perf: avoid repeated Claude tool-name lookups * refactor(relaykit): name tool-result backfill type and drop unused lookup Replace the repeated anonymous struct in the Claude-to-chat converter with a local named type, and remove SearchToolNameByToolCallId now that the converter resolves tool names in a single pass and nothing else calls it.
* perf: avoid repeated Claude tool-name lookups * refactor(relaykit): name tool-result backfill type and drop unused lookup Replace the repeated anonymous struct in the Claude-to-chat converter with a local named type, and remove SearchToolNameByToolCallId now that the converter resolves tool names in a single pass and nothing else calls it.
* perf: avoid repeated Claude tool-name lookups * refactor(relaykit): name tool-result backfill type and drop unused lookup Replace the repeated anonymous struct in the Claude-to-chat converter with a local named type, and remove SearchToolNameByToolCallId now that the converter resolves tool names in a single pass and nothing else calls it.
* perf: avoid repeated Claude tool-name lookups * refactor(relaykit): name tool-result backfill type and drop unused lookup Replace the repeated anonymous struct in the Claude-to-chat converter with a local named type, and remove SearchToolNameByToolCallId now that the converter resolves tool names in a single pass and nothing else calls it.
Related Issue
None. This is a focused performance improvement, not a new feature or a bug fix requiring a linked issue.
Type of change
Description
When converting a
/v1/messagesrequest to/v1/chat/completions, eachtool_resultwithout a name previously triggeredSearchToolNameByToolCallId. Each lookup scanned the message list and parsedmessage content again, causing repeated serialization and deserialization as
the number of tool results grew. On requests with long message histories and
many tool results, this can cause substantial CPU usage.
The converter now records tool names while parsing the input messages once
and fills in unnamed tool results after traversal. This preserves explicit
names, first-match behavior for duplicate IDs, and results that reference a
tool call later in the message list.
The code and PR description were prepared with AI assistance and reviewed by
the submitter.
Proof of Work
names, and unknown IDs.
GOWORK=off go test ./relayconvert -run TestConvertRequestClaudeToChatResolvesToolResultNames -count=1— passed.GOWORK=off go build ./...— passed.Checklist
Summary by CodeRabbit
Bug Fixes
Tests