Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Proposed change of Docs: prevent overwriting Long Running Function Tool #1988

@chenhao81

Description

@chenhao81

What part of the docs needs improvement?

https://google.github.io/adk-docs/tools/function-tools/#intermediate-final-result-updates

in the sample python code

Current text / code

long_running_function_call, long_running_function_response, ticket_id = None, None, None
async for event in events_async:
    if not long_running_function_call:
        long_running_function_call = get_long_running_function_call(event)
    else:
        long_running_function_response = get_function_response(
            event, long_running_function_call.id
        )
        if long_running_function_response:
            ticket_id = long_running_function_response.response['ticket-id']

 Proposed change

if not long_running_function_call:
    long_running_function_call = get_long_running_function_call(event)
- else:
+ elif not long_running_function_response:

Only attempt to capture the FunctionResponse once; subsequent events may be plain chat messages.

Why

Some LLM backends (e.g. qwen‑plus in my case) emit an additional text event for user‑visible chat message after they got the FunctionResponse.
The current else: branch runs on that extra event, get_function_response() returns None, and the variable is unintentionally reset. As a result, the if long_running_function_response: block never triggers and the sample stops before forwarding the final status.

Guarding with elif not long_running_function_response keeps the original FunctionResponse intact and makes the example behave correctly across different model streams, reducing confusion for newcomers.

Thanks for considering!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bot triaged[Bot] This issue is triaged by ADK botdocumentation[Component] This issue is related to documentation, it will be transferred to adk-docs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions