Skip to content

fix: filter adk_request_confirmation events from LLM history#683

Open
odsod wants to merge 1 commit intogoogle:mainfrom
odsod:fix/confirmation-event-filter-contents-processor
Open

fix: filter adk_request_confirmation events from LLM history#683
odsod wants to merge 1 commit intogoogle:mainfrom
odsod:fix/confirmation-event-filter-contents-processor

Conversation

@odsod
Copy link
Copy Markdown

@odsod odsod commented Mar 26, 2026

Description

buildContentsDefault in contents_processor.go filters adk_request_credential events from LLM history via isAuthEvent(), but has no equivalent for adk_request_confirmation events.

When using a persistent session store (anything other than InMemorySessionService), confirmation events are replayed into the Gemini context on the next turn, causing a 400 error — Gemini sees FunctionCall/FunctionResponse parts for adk_request_confirmation, a function it never declared.

Changes

  • Add isConfirmationEvent() function in contents_processor.go, mirroring isAuthEvent()
  • Wire it into buildContentsDefault to skip confirmation events
  • Add 3 test cases: FunctionCall event, FunctionResponse event, and mixed history with confirmation events interleaved

Testing

go test ./internal/llminternal/ -run "TestContentsRequestProcessor$" -v

All existing tests pass. New tests:

  • ConfirmationFunctionCallEvent — verifies FunctionCall with adk_request_confirmation is filtered
  • ConfirmationFunctionResponseEvent — verifies FunctionResponse with adk_request_confirmation is filtered
  • ConfirmationEventsFilteredFromHistory — verifies confirmation events are stripped while regular tool call events are preserved

Fixes #682

Comment thread internal/llminternal/contents_processor.go Outdated
@odsod odsod force-pushed the fix/confirmation-event-filter-contents-processor branch from 5123c11 to db18fed Compare March 26, 2026 11:19
When the tool confirmation (HITL) flow injects adk_request_confirmation
FunctionCall/FunctionResponse parts into the session history, these
must not be sent back to the LLM — the model never declared this
function and will reject or misinterpret it.

Add isConfirmationEvent to the contents processor to strip these
events during history construction, mirroring the existing
isAuthEvent filter for adk_request_credential.
@odsod odsod force-pushed the fix/confirmation-event-filter-contents-processor branch from db18fed to f3152cb Compare March 26, 2026 18:27
@odsod odsod requested a review from w1t March 27, 2026 06:22
@odsod
Copy link
Copy Markdown
Author

odsod commented Apr 11, 2026

@w1t hi! anything more I can do on this one, or do you think we can get this included in the next release?

@verdverm
Copy link
Copy Markdown

want to confirm this filtering only happens during message creation and that confirmations are persisted to the session store for compliance

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

contents_processor.go missing isConfirmationEvent filter breaks tool confirmation with persistent session stores

3 participants