Skip to content

fix interactions SSE ids for function calls #5177

Open
kshirajahere wants to merge 2 commits intogoogle:mainfrom
kshirajahere:codex/fix-interactions-sse-ids
Open

fix interactions SSE ids for function calls #5177
kshirajahere wants to merge 2 commits intogoogle:mainfrom
kshirajahere:codex/fix-interactions-sse-ids

Conversation

@kshirajahere
Copy link
Copy Markdown

What changed

  • preserve interaction chain IDs in Interactions API SSE mode by reading the SDK's actual streaming fields (interaction.id, interaction_id, event_id) instead of only event.id
  • treat interaction.complete as the final full interaction event during streaming conversion
  • add regression coverage for interaction.complete handling and for SSE function-call streams that must retain the interaction ID before the tool round-trip

Why

Issue #5169 reports that StreamingMode.SSE breaks Interactions API function calling because the second model call cannot find the previous interaction_id in session history.

The root cause is that ADK's SSE adapter was keyed to older/generic event shapes (event.id and event_type == "interaction"), while google-genai 1.70.0 emits interaction.start, interaction.complete, and interaction.status_update events with IDs stored on interaction.id, interaction_id, and event_id.

That mismatch meant streamed function-call events were persisted without an interaction_id, so the next round of the ReAct loop could not chain the interaction and failed with invalid_request.

Impact

  • restores function-calling flows for Gemini(use_interactions_api=True) when SSE streaming is enabled
  • keeps the interaction chain intact in session events so follow-up tool/result turns can resume correctly
  • improves compatibility with the current GenAI SDK SSE event schema without changing non-streaming behavior

Validation

  • .venv\\Scripts\\pytest tests\\unittests\\models\\test_interactions_utils.py tests\\unittests\\flows\\llm_flows\\test_interactions_processor.py tests\\unittests\\models\\test_google_llm.py -q
  • .venv\\Scripts\\pyink --check --config pyproject.toml src\\google\\adk\\models\\interactions_utils.py tests\\unittests\\models\\test_interactions_utils.py
  • .venv\\Scripts\\isort --check-only src\\google\\adk\\models\\interactions_utils.py tests\\unittests\\models\\test_interactions_utils.py
  • .venv\\Scripts\\pylint --rcfile=pylintrc src\\google\\adk\\models\\interactions_utils.py

Fixes google#5169 by reading interaction IDs from the actual GenAI SDK SSE event fields and carrying them through streaming function-call responses. Also adds regression coverage for interaction.complete events and streaming interaction.start chaining.
@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Apr 6, 2026
Rename the thought-content temporary variable so the repo's mypy new-errors workflow does not treat a shifted baseline no-redef diagnostic as a newly introduced error.
@kshirajahere
Copy link
Copy Markdown
Author

Local validation is green on this branch:\n\n- pytest tests/unittests/models/test_interactions_utils.py tests/unittests/flows/llm_flows/test_interactions_processor.py tests/unittests/models/test_google_llm.py -q\n- pyink --check --config pyproject.toml src/google/adk/models/interactions_utils.py tests/unittests/models/test_interactions_utils.py\n- isort --check-only src/google/adk/models/interactions_utils.py tests/unittests/models/test_interactions_utils.py\n- pylint --rcfile=pylintrc src/google/adk/models/interactions_utils.py\n- local check-file-contents verification against origin/main\n- no new mypy error lines relative to origin/main for src/google/adk/models/interactions_utils.py\n\nThe remaining GitHub Actions jobs are currently in �ction_required because this is a forked PR and upstream workflow approval is needed before they can actually run.

@kshirajahere kshirajahere marked this pull request as ready for review April 7, 2026 03:21
@kshirajahere kshirajahere changed the title [codex] fix interactions SSE ids for function calls fix interactions SSE ids for function calls Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core [Component] This issue is related to the core interface and implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants