adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

Feature: Stream partial function-call arguments across model adapters

Open FrigaZzz opened this issue 3 months ago • 2 comments

🔴 Required Information

Is your feature request related to a specific problem?

Yes.

When using stream=True, several ADK model adapters currently buffer function-call argument deltas internally and only emit a completed FunctionCall after the model has finished generating the tool invocation.

As a result, applications receive token-by-token text updates but no visibility into function-call generation progress. For large schemas or complex tool arguments, this can create several seconds of apparent inactivity even though the provider is actively streaming tool-call data.

This behavior is inconsistent across providers and differs from the native Gemini progressive streaming experience, where intermediate function-call information can already be surfaced.

Affected adapters appear to include:

  • LiteLLM (also discussed in #5342)
  • OpenAI Chat Completions
  • OpenAI Responses / Azure Responses
  • Anthropic
  • Apigee OpenAI-compatible Chat Completions

Describe the Solution You'd Like

I would like ADK to expose function-call argument streaming through the existing streaming contract.

When an adapter receives a function-call start event or argument delta during a stream=True request:

  1. Emit LlmResponse(partial=True) updates.
  2. Surface raw incremental argument fragments through FunctionCall.partial_args.
  3. Mark intermediate updates with FunctionCall.will_continue=True.
  4. Continue emitting the current final aggregated FunctionCall containing parsed args when generation completes.
  5. Preserve stable function-call IDs across parallel or interleaved tool calls.

Partial updates should remain informational only and must never trigger tool execution.

Ideally, this would require no new public API, feature flag, configuration option, or wrapper abstraction. The change could remain localized within existing adapter streaming loops.

Impact on your work

This would significantly improve real-time UX for streaming agent applications.

Currently, users can observe normal text streaming but see no activity while a model constructs a large function call. Exposing partial function-call updates would allow UIs to display ongoing tool invocation progress and provide a more responsive experience.

This is particularly useful for:

  • Large structured tool schemas
  • Multi-agent workflows
  • Multi-tool orchestration
  • Interactive chat and agent UIs
  • Long-running streaming sessions

I do not have a strict timeline for this feature, but it would be valuable for production streaming experiences.

Willingness to contribute

Yes

I would be interested in implementing the change and contributing a PR if the proposed behavior aligns with ADK's design goals.


🟡 Recommended Information

Describe Alternatives You've Considered

Current alternatives include:

  • Waiting for the final aggregated function call before updating the UI.
  • Implementing provider-specific streaming logic outside of ADK.
  • Relying on Gemini-specific behavior where available.

These approaches either reduce responsiveness or require provider-specific handling that bypasses ADK's abstraction layer.

Proposed API / Implementation

No public API changes are required.

Example behavior:

# Intermediate update

yield LlmResponse(
    partial=True,
    content=Content(
        parts=[
            Part(
                function_call=FunctionCall(
                    id=call_id,
                    name=function_name,
                    partial_args=types.PartialArg(
                        string_value=argument_delta
                    ),
                    will_continue=True,
                )
            )
        ]
    ),
)

# Existing final aggregated update

yield LlmResponse(
    partial=False,
    content=Content(
        parts=[
            Part(
                function_call=FunctionCall(
                    id=call_id,
                    name=function_name,
                    args=parsed_args,
                )
            )
        ]
    ),
)

Possible event mappings:

Provider Streaming Event
OpenAI Chat delta.tool_calls
OpenAI Responses / Azure Responses response.function_call_arguments.delta
Anthropic InputJSONDelta.partial_json
LiteLLM FunctionChunk
Apigee OpenAI-compatible Tool-call delta events

Additional Context

Suggested acceptance criteria:

  • Partial argument events are emitted for LiteLLM, OpenAI Chat, OpenAI Responses/Azure Responses, Anthropic, and Apigee Chat Completions whenever raw argument deltas are available.
  • Native Gemini, Interactions, and Gemini Live streaming behavior remains unchanged.
  • Incomplete JSON never appears in FunctionCall.args during partial updates.
  • Partial responses never trigger tool execution.
  • Existing final aggregated streaming responses remain unchanged.
  • stream=False behavior remains unchanged.

FrigaZzz avatar Aug 07 '26 13:08 FrigaZzz

Hi @FrigaZzz, thank you for the feature request. If you have a solution in mind, please feel free to submit a PR; our team would be happy to review it.

sanketpatil06 avatar Aug 11 '26 11:08 sanketpatil06

Hi @FrigaZzz, thank you for the feature request. If you have a solution in mind, please feel free to submit a PR; our team would be happy to review it.

Hi! Thanks for getting back to me.

I've put together a PR with a solution specifically for the OpenAI model wrapper (you can see it here: #6679).

I’m planning to add support for other providers soon, but I currently can't test certain clients directly because I don't have the necessary API tokens for them. I've laid the groundwork, but I'm hoping others in the community might be able to jump in, help test those environments, or contribute the missing pieces!

Let me know what you think of the initial implementation. Happy to make adjustments based on your review!

FrigaZzz avatar Aug 11 '26 12:08 FrigaZzz