Skip to content

fix(adk): validate ask_user questions - #2486

Merged
EItanya merged 4 commits into
kagent-dev:release/v0.10.xfrom
erauner12:fix/v0.10-ask-user-question-validation
Aug 20, 2026
Merged

fix(adk): validate ask_user questions#2486
EItanya merged 4 commits into
kagent-dev:release/v0.10.xfrom
erauner12:fix/v0.10-ask-user-question-validation

Conversation

@erauner12

Copy link
Copy Markdown
Contributor

Summary

Validate built-in ask_user inputs in both Go and Python ADK runtimes on release/v0.10.x before confirmation handling.

Fixes #2468.

Problem

Both implementations accepted an empty questions list and entries whose question text was empty or whitespace-only. Those invalid calls could pause a task without presenting a usable question.

An invalid model tool call should return an error the model can correct; it should not create an unanswerable input-required interaction.

Change

Both runtimes now:

  • require at least one question;
  • require nonblank question text for every entry;
  • reject invalid input before requesting confirmation;
  • tell the model to provide at least one question; and
  • preserve existing pending and confirmed behavior for valid questions.

Runtime validation remains authoritative and does not depend on a provider enforcing a generated schema.

Tests

Go:

  • go test ./adk/pkg/tools
  • go test -race ./adk/pkg/tools

Python:

  • uv run pytest packages/kagent-adk/tests/unittests/test_ask_user_tool.py packages/kagent-adk/tests/unittests/test_hitl.py -q
  • Ruff checks on the touched Python files

Coverage verifies empty-list rejection, blank-text rejection, no confirmation call for invalid input, and unchanged valid pending/confirmed behavior in both runtimes.

Validation

An independent A2A client against a compatible v0.10 deployment completed a valid structured-question round trip: one nonblank question was returned, a later process answered the retained interaction, and the same task reached terminal completion without resending the original request.

This PR changes only built-in ask_user validation; it does not change identity propagation, persistence, or A2A transport formats.

Signed-off-by: Evan Rauner <raunerevan@gmail.com>
@github-actions github-actions Bot added the bug Something isn't working label Aug 18, 2026
@erauner12
erauner12 marked this pull request as ready for review August 18, 2026 22:03
@erauner12
erauner12 requested review from a team and supreme-gg-gg as code owners August 18, 2026 22:03
Copilot AI lite review requested due to automatic review settings August 18, 2026 22:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens validation for the built-in ask_user tool in both the Go and Python ADK runtimes to prevent creating unusable HITL interactions (e.g., empty questions or whitespace-only question text), aligning behavior with the intent of returning correctable tool-call errors instead of pausing execution without a usable prompt.

Changes:

  • Add runtime validation to require at least one question and require each question’s text to be non-blank (Go + Python).
  • Ensure invalid inputs fail fast (before calling the confirmation mechanism), while preserving pending/confirmed behavior for valid inputs.
  • Add focused unit tests in both languages covering empty/blank rejection and confirmation-call behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
python/packages/kagent-adk/src/kagent/adk/tools/ask_user_tool.py Adds validation for empty/blank questions and ensures confirmation is only requested for valid inputs.
python/packages/kagent-adk/tests/unittests/test_ask_user_tool.py Adds async tests ensuring invalid inputs error without confirmation and valid flows remain unchanged.
go/adk/pkg/tools/ask_user.go Adds input validation prior to confirmation request for empty/blank questions.
go/adk/pkg/tools/ask_user_test.go Adds Go unit tests asserting invalid inputs don’t request confirmation and valid flows behave as expected.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +60 to 62
"Ask the user at least one question and wait for their answers before continuing. "
"Every question must include non-empty text. Use this when you need clarifying information, "
"preferences, or explicit confirmation from the user."
Comment on lines +23 to 25
const askUserDescription = "Ask the user at least one question and wait for their answers before continuing. " +
"Every question must include non-empty text. Use this when you need clarifying information, " +
"preferences, or explicit confirmation from the user."
@erauner12

Copy link
Copy Markdown
Contributor Author

Forward-port note

This validation fix is independent of #2483#2485. A main-oriented implementation is available in erauner12#14; its production behavior is equivalent to this PR. A forward-port should retain the provider-independent runtime guards and valid pending/confirmed behavior while adapting tests to current main APIs if they have moved.

@erauner12

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

@erauner12

erauner12 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

CI update

The only remaining required check is Playwright E2E, failing on the unrelated missing-session UI assertion in chat-errors.spec.ts. This PR changes only the Go and Python ask_user implementations; all Go, Python, UI unit, build, upgrade, and other E2E checks passed.

The current release/v0.10.x run passed this same Playwright test, while another PR based on the same release tip failed a different Playwright CRUD case. That points to a test-environment/harness flake rather than an ask_user regression.

Next step is to rerun the failed Playwright job once. GitHub does not permit the PR author to rerun this upstream workflow, so a maintainer will need to select Re-run failed jobs. If the same failure reproduces, I’ll inspect the uploaded trace/screenshot before proposing any change; no code change is warranted from this result alone.

@supreme-gg-gg could you take a look?

@EItanya
EItanya merged commit 4720b22 into kagent-dev:release/v0.10.x Aug 20, 2026
31 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants