Elicittion (Ambiguity Resolution) Feature in Google ADK.#5670
Open
suddhasatwabhaumik wants to merge 1 commit into
Open
Elicittion (Ambiguity Resolution) Feature in Google ADK.#5670suddhasatwabhaumik wants to merge 1 commit into
suddhasatwabhaumik wants to merge 1 commit into
Conversation
Author
|
Hi @wukath Please have a look at this PR, or recommend whom I can reach out to for review/approval. Thank you! |
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.
Note: read the contribution guide before creating this pull request.
Link to Issue or Description of Change
Problem:
When building conversational agents, users often provide ambiguous or incomplete prompts (e.g., "Book a hotel in Tokyo" without specifying dates/guests, or "Show me active customers" in an NL2SQL interface without specifying filters). Prior to this change, agents had no structured, out-of-the-box way to dynamically request clarification (elicitation) from users without either:
Solution:
We implemented the Stateless Tiered Elicitation Pattern in the Google ADK. This feature enables fully stateless, interactive, multi-turn ambiguity resolution. The runner packages the current turn state into a
hidden_contextpayload returned to the client; on the next turn, the runner transparently rehydrates this context, passing the completed inputs back to the model.Key architectural additions:
a2a.py): AddedAgentResponseStatus.ELICITATION_REQUIREDand defined theElicitationDataPydantic schema to encapsulatecontext_snapshotandturn_count.elicitation.py): Implemented_ElicitationRequestProcessorand_ElicitationResponseProcessorwithin theSingleFlowrequest/response pipeline to handle transparent state rehydration and elicitation interception.elicitation_tool.py): CreatedTriggerElicitationTool, which is conditionally injected by the ADK runner. The model invokes this tool to signal exactly which entity slots are missing.llm_agent.py,llm_agent_config.py): Addedallow_elicitation(bool) andelicitation_max_turns(int) configuration properties to allow developers fine-grained control.turn_countexceedselicitation_max_turns, it raises aRuntimeErrorto abort infinite execution loops gracefully.contributing/samples/stateless_elicitation/): Built a fully runnable travel booking assistant sample demonstrating multi-turn rehydration, detailed architectural sequence diagrams, and critical security guidelines (preventing PII leakage and state tampering).Testing Plan
We have implemented extensive automated unit and integration tests to verify this feature end-to-end under multiple conditions.
Unit Tests:
Summary of passed
pytestresults (PYTHONPATH=src .venv/bin/pytest tests/unittests/flows/llm_flows/test_elicitation.py):Manual End-to-End (E2E) Tests:
We built a dedicated E2E integration test using the
AgentEvaluatorframework.tests/integration/test_elicitation_flow.pytests/integration/fixture/elicitation_agent/Local runner E2E verification of the new sample (
contributing/samples/stateless_elicitation/main.py):Error: Missing required LLM credentials. Please set the GOOGLE_API_KEY environment variable before running this sample.Checklist
Additional context
This feature is highly valuable for many real-world cross-industry use cases like the following examples, and many more: