Skip to content

fix: Anthropic non-streaming function_call property casing#620

Open
MarvelNwachukwu wants to merge 2 commits intomainfrom
fix-anthropic-function-call
Open

fix: Anthropic non-streaming function_call property casing#620
MarvelNwachukwu wants to merge 2 commits intomainfrom
fix-anthropic-function-call

Conversation

@MarvelNwachukwu
Copy link
Contributor

@MarvelNwachukwu MarvelNwachukwu commented Mar 19, 2026

Description

When using Anthropic models (like Claude) in non-streaming mode, tool calls were silently failing — the agent would ignore tools and never execute them. This happened because of a simple naming mismatch: the code was using function_call (with underscores) but the rest of the system expects functionCall (camelCase). The streaming mode already used the correct naming, so this only affected non-streaming requests.

TL;DR: Anthropic tool use was broken in non-streaming mode. Now it works.

Why

This fix is necessary because tool use is a core capability of the ADK framework. With the non-streaming Anthropic path broken, any agent using Anthropic models without streaming could not execute tools — function calls were silently dropped by Event.getFunctionCalls() and Event.getFunctionResponses() since they look for camelCase properties. This caused agents to appear to ignore their tools entirely, producing incorrect responses instead of invoking the appropriate tool. The fix ensures parity between streaming and non-streaming modes, and consistency with how other LLM providers (OpenAI, AI SDK) handle function call properties.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

How Has This Been Tested?

All 478 existing tests pass, including the updated Anthropic LLM conversion tests.

Checklist

  • My code follows the code style of this project
  • All new and existing tests passed
  • My changes generate no new warnings

… call properties

The non-streaming path in anthropic-llm.ts was using snake_case (function_call,
function_response) for part properties, but the Event API expects camelCase
(functionCall, functionResponse). The streaming path already uses camelCase correctly.
This caused tool use to silently break in non-streaming Anthropic mode.

Fixes: Non-streaming Anthropic tool calls are now properly recognized by getFunctionCalls()
Tests: All 478 tests pass
@vercel
Copy link
Contributor

vercel bot commented Mar 19, 2026

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

Project Deployment Actions Updated (UTC)
adk-typescript-docs Ready Ready Preview Mar 19, 2026 3:36pm
adk-web Ready Ready Preview Mar 19, 2026 3:36pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Mar 19, 2026

🦋 Changeset detected

Latest commit: 621aa3f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@iqai/adk Patch
@iqai/adk-cli Patch
@iqai/mcp-docs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gemini-code-assist
Copy link
Contributor

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 addresses a bug impacting Anthropic's non-streaming tool use functionality by standardizing the casing of function call and response properties. The change ensures that the system correctly processes tool-related events, which previously failed due to an inconsistency in how these properties were named, thereby restoring expected behavior for tool interactions.

Highlights

  • Bug Fix: Anthropic Non-Streaming Tool Use: Resolved a critical bug where Anthropic non-streaming tool use silently failed due to a casing mismatch in function_call and function_response properties. These properties were incorrectly returned in snake_case instead of the expected camelCase (functionCall, functionResponse), preventing Event.getFunctionCalls() and Event.getFunctionResponses() from correctly identifying them.
  • Property Casing Correction: Updated the AnthropicLlm class to consistently use functionCall and functionResponse (camelCase) for handling tool use properties in both directions of conversion (to and from Anthropic message content blocks).
  • Test Suite Updates: Modified existing Anthropic LLM conversion tests to align with the corrected camelCase property names, ensuring the fix is properly validated.
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.

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.

@MarvelNwachukwu
Copy link
Contributor Author

@claude do a deep review

@claude
Copy link
Contributor

claude bot commented Mar 19, 2026

Claude finished @MarvelNwachukwu's task —— View job


Deep PR Review Complete ✅

This PR fixes a critical bug in the Anthropic non-streaming implementation that was causing tool use to silently fail. Here's my comprehensive review:

Review Tasks:

  • Analyze the changed files and understand the bug
  • Review the fix implementation for correctness
  • Examine test changes and coverage
  • Check for potential edge cases or side effects
  • Evaluate overall solution completeness
  • Provide detailed feedback and recommendations

🐛 Bug Analysis

Root Cause: The non-streaming path in AnthropicLlm was using snake_case (function_call, function_response) while the Event system expects camelCase (functionCall, functionResponse). Since Event.getFunctionCalls() and Event.getFunctionResponses() specifically look for camelCase properties, tool calls were being silently ignored.

Impact: Complete failure of tool use in non-streaming Anthropic mode, while streaming worked correctly.

Fix Correctness

The fix is technically sound and addresses the root cause:

  1. partToAnthropicBlock() method: Fixed lines 405 & 412 to check for part.functionCall and part.functionResponse (camelCase)
  2. anthropicBlockToPart() method: Fixed line 429 to return functionCall property (camelCase)
  3. Streaming consistency: The streaming path at line 279-284 was already correct, using functionCall camelCase

🧪 Test Coverage

The test updates are appropriate and sufficient:

  • Updated 3 test cases in anthropic-llm.test.ts to use camelCase properties
  • Tests verify both directions: ADK-TS ↔ Anthropic conversions
  • Existing streaming tests already covered the correct camelCase format

🔍 Edge Cases & Side Effects

No negative impacts identified:

  • ✅ Backwards compatibility maintained (only affects internal conversions)
  • ✅ Streaming path unaffected (already correct)
  • ✅ Other model implementations (OpenAI, AI SDK) consistently use camelCase
  • ✅ No additional snake_case references found in core model code

📋 Overall Assessment

STRENGTHS:

  • ✅ Fixes a silent failure mode that's hard to debug
  • ✅ Aligns with framework-wide camelCase conventions
  • ✅ Minimal, targeted change with clear intent
  • ✅ Comprehensive test coverage of the fix
  • ✅ Consistent with other LLM implementations in the codebase

RECOMMENDATIONS:

  1. Consider adding integration tests that verify end-to-end tool usage in non-streaming mode
  2. Documentation enhancement: Consider adding a comment about the camelCase requirement in the conversion methods
  3. Runtime validation: Could add property existence checks in getFunctionCalls()/getFunctionResponses() to catch similar issues early

🎯 Verdict

This is a high-quality bug fix that resolves a critical issue with minimal risk. The change is well-tested, follows established conventions, and restores expected functionality.

Recommendation: APPROVE

The fix is production-ready and should resolve the tool use failures in Anthropic non-streaming mode.


Copy link
Contributor

@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 correctly addresses a casing mismatch for functionCall and functionResponse properties within the Anthropic non-streaming implementation. The changes in anthropic-llm.ts align the property names to the expected camelCase format, which resolves an issue causing tool use to fail silently. The corresponding test updates in anthropic-llm.test.ts are also correct and ensure the fix is verified. The changes are accurate and well-contained.

@kesar
Copy link
Member

kesar commented Mar 19, 2026

can you add in the PR why we are working on this?

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.

fix: anthropic non-streaming function call property casing

2 participants