Skip to content

feat: optional concurrent async automatic function calling - #2813

Open
a2105z wants to merge 2 commits into
googleapis:mainfrom
a2105z:feat/concurrent-async-afc
Open

feat: optional concurrent async automatic function calling#2813
a2105z wants to merge 2 commits into
googleapis:mainfrom
a2105z:feat/concurrent-async-afc

Conversation

@a2105z

@a2105z a2105z commented Aug 4, 2026

Copy link
Copy Markdown

Summary

  • Fixes #2281: add optional AutomaticFunctionCallingConfig.run_concurrently so async automatic function calling can execute multiple tool calls from one model response concurrently via asyncio.gather.
  • Default behavior stays sequential; sync AFC is unchanged.
  • Wires the flag through async generate_content / generate_content_stream and adds unit tests for order, concurrency, and default sequential execution.

Test plan

  • pytest google/genai/tests/afc/test_get_function_response_parts.py (9 passed)
  • Covers run_concurrently=True async gather path; default remains sequential; sync AFC unchanged
  • CI green
  • Optional: async generate_content with two slow tools + run_concurrently=True finishes near one-tool latency

Add AutomaticFunctionCallingConfig.run_concurrently so async AFC can
execute multiple tool calls from one model response via asyncio.gather.
Defaults remain sequential. Fixes googleapis#2281.
@a2105z

a2105z commented Aug 4, 2026

Copy link
Copy Markdown
Author

@Venkaiahbabuneelam this PR adds optional AutomaticFunctionCallingConfig.run_concurrently for parallel async tool execution via asyncio.gather; whenever you have a moment, I would really appreciate your review — thank you for your time.

@Venkaiahbabuneelam Venkaiahbabuneelam self-assigned this Aug 4, 2026
@Venkaiahbabuneelam Venkaiahbabuneelam added the size:XL Code changes > 100 lines label Aug 4, 2026
Annotate func_response as StringDict so the error-path assignment type
checks after concurrent AFC extraction.
@a2105z

a2105z commented Aug 4, 2026

Copy link
Copy Markdown
Author

@Venkaiahbabuneelam sorry — mypy failed on this one too. Different issue than the MCP PR: after extracting the async helper, the error-path dict typing got messed up. Pushed a fix; local mypy is clean now. If you can re-approve / re-run checks when you get a chance thatd be awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL Code changes > 100 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable (optional) concurrent execution of function calls in get_function_response_parts_async

2 participants