Validate session initialization events#5291
Open
petrmarinec wants to merge 1 commit intogoogle:mainfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5290.
This change prevents client-supplied session initialization events from seeding ADK runtime/tool protocol state. Session initialization still accepts non-runtime conversation history, but rejects events containing function calls, function responses, long-running tool ids, or internal runtime
EventActionsfields.It also tightens HITL confirmation resumption so
adk_request_confirmationresponses only resume tool calls that are backed by prior original function-call state and priorrequested_tool_confirmationsmetadata in the event history.Why
CreateSessionRequest.eventsis accepted from the HTTP API and appended to the new session. Those events should not be able to spoof ADK-generated runtime control state. Without this validation, a client can seed confirmation-shaped events and later send a matching confirmation response that causes a registered tool call embedded inoriginalFunctionCallto be resumed.Tests
python -m pyink --check src/google/adk/flows/llm_flows/request_confirmation.py src/google/adk/cli/adk_web_server.py tests/unittests/flows/llm_flows/test_request_confirmation.py tests/unittests/cli/test_fast_api.pypython -m pytest tests/unittests/flows/llm_flows/test_request_confirmation.py tests/unittests/cli/test_fast_api.py::test_create_session_accepts_initial_text_events tests/unittests/cli/test_fast_api.py::test_create_session_rejects_runtime_tool_events tests/unittests/cli/test_fast_api.py::test_create_session_rejects_runtime_action_events tests/unittests/runners/test_run_tool_confirmation.py -qResult: 17 passed.
Additional local check:
tests/unittests/cli/test_fast_api.pypasses on Windows with known baseline-local failures excluded: 61 passed, 4 deselected. The excluded cases are two CRLF assertion failures in builder GET tests and two A2A temporary-directory teardown errors; I reproduced those same failures on cleanorigin/main.Checklist