Skip to content

Fix Azure 40 character limit on tool_call_id#5575

Merged
colegottdank merged 1 commit intomainfrom
fix/azure-long-tool-call-id
Feb 17, 2026
Merged

Fix Azure 40 character limit on tool_call_id#5575
colegottdank merged 1 commit intomainfrom
fix/azure-long-tool-call-id

Conversation

@colegottdank
Copy link
Collaborator

Summary

  • Azure rejects tool_call_ids longer than 40 characters
  • Adds truncateToolCallId function that deterministically shortens long IDs using a hash suffix
  • Ensures the same truncated ID is used for both the assistant tool_call and the corresponding tool response
  • Adds tests for long ID truncation

Test plan

  • Unit tests pass for long ID truncation
  • Unit tests pass for short ID preservation
  • Test in production with Azure after deployment

🤖 Generated with Claude Code

Azure rejects tool_call_ids longer than 40 characters. This adds a
truncateToolCallId function that deterministically shortens long IDs
using a hash suffix, ensuring the same ID is used for both the
assistant tool_call and the corresponding tool response.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Feb 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
helicone Ready Ready Preview, Comment Feb 17, 2026 6:47am
helicone-bifrost Ready Ready Preview, Comment Feb 17, 2026 6:47am
helicone-eu Ready Ready Preview, Comment Feb 17, 2026 6:47am

Request Review

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@supabase
Copy link

supabase bot commented Feb 17, 2026

This pull request has been ignored for the connected project bolqqmqbrciybnypvklh because there are no changes detected in supbase/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@supabase
Copy link

supabase bot commented Feb 17, 2026

This pull request has been ignored for the connected project lmahfbbnchpworytrrqk because there are no changes detected in .supabase/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@claude
Copy link
Contributor

claude bot commented Feb 17, 2026

Claude finished @colegottdank's task —— View job


PR Review: Fix Azure 40 character limit on tool_call_id

Todo List:

  • Read and analyze the changed files
  • Review the truncateToolCallId implementation
  • Examine test coverage and quality
  • Check for potential issues and edge cases
  • Provide structured feedback with confidence score

Analysis Complete

I've thoroughly reviewed both changed files. The implementation adds a truncateToolCallId function to handle Azure's 40-character limit on tool_call_ids, with comprehensive test coverage.

Score: 8/10 - Good implementation with minor suggestions for improvement

Detailed Review:

Strengths:

  1. Clear Problem Statement: Well-documented Azure limitation (40 char limit) with clear comments
  2. Deterministic Approach: Same input produces same output, ensuring tool_calls match their responses
  3. Comprehensive Test Coverage: Tests both long ID truncation and short ID preservation
  4. Edge Case Handling: Properly handles missing IDs with fallback generation
  5. Non-Breaking: Short IDs (<= 40 chars) are preserved unchanged

🔧 Minor Suggestions:

  1. Hash Collision Risk: While unlikely, the current hash function could theoretically produce collisions. Consider using a more robust hash (crypto.createHash) for better uniqueness:

    import crypto from 'crypto';
    
    function truncateToolCallId(id: string): string {
      if (id.length <= AZURE_TOOL_CALL_ID_LIMIT) {
        return id;
      }
      // More robust hash to minimize collision risk
      const hash = crypto.createHash('sha256').update(id).digest('hex').slice(0, 8);
      const prefixLength = AZURE_TOOL_CALL_ID_LIMIT - hash.length - 1;
      return `${id.substring(0, prefixLength)}_${hash}`;
    }
  2. Error Handling: Consider validation for empty/null IDs, though current fallback logic handles this adequately

  3. Documentation: Could add JSDoc comment explaining the hash algorithm choice

🧪 Test Quality:

  • Excellent test coverage with realistic scenarios
  • Tests verify deterministic behavior (same input → same output)
  • Covers both truncation and preservation cases
  • Integration tests ensure end-to-end functionality

🚀 Performance:

  • Minimal overhead - only processes long IDs
  • Simple hash function is fast for typical ID lengths
  • No unnecessary string operations

Suggestions Summary:

  • Consider using crypto hash for better collision resistance (optional improvement)
  • Add JSDoc documentation for the hash algorithm choice
  • Current implementation is solid and ready to merge

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.

1 participant