Skip to content

fix(runners): hide thoughts from nonverbose debug output - #7452

Closed
BlueRaddish wants to merge 1 commit into
google:mainfrom
BlueRaddish:fix/oct7-hide-debug-thoughts
Closed

BlueRaddish wants to merge 1 commit into
google:mainfrom
BlueRaddish:fix/oct7-hide-debug-thoughts

Conversation

@BlueRaddish

Copy link
Copy Markdown
Contributor

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

Problem: InMemoryRunner.run_debug(verbose=False) promises output showing only final agent responses, but the shared event printer includes Part(thought=True) text. A response containing a thought followed by an answer is printed as test_agent > thinking answer; a thought-only event is also printed.

Solution: Skip thought parts in nonverbose output. Preserve the existing verbose output for debugging and retain all original parts in the events returned by run_debug. No model configuration, session persistence, or event serialization changes.

Reproduction: A deterministic BaseAgent yields an Event with a thought part followed by an answer part. Running it with the public InMemoryRunner.run_debug entry point prints the thought on the base revision; the same invocation with this change prints only test_agent > answer. No inference service or external network is involved.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All relevant unit tests pass locally.
python -m pytest tests/unittests/utils/test_debug_output.py tests/unittests/test_runners.py -k 'print_event or run_debug' -q

Result: 20 passed, 182 deselected. Before the fix, the printer tests had 2 failed, 15 passed, and the public runner tests had 1 failed, 2 passed. Coverage includes a mixed thought/answer event, a thought-only event, verbose output, and preservation of the thought in returned events. The full ADK suite was not run.

Manual End-to-End (E2E) Tests: The two parameterized test_run_debug_hides_thoughts_unless_verbose cases execute the real public runner, a deterministic custom BaseAgent, and real in-memory session services. They exercise both console modes without mocking the printer or running a model. The nonverbose case failed on the base revision and passes after the fix.

All repository pre-commit hooks passed on the exact diff in a native Linux checkout of the same base revision. Windows tests use Python 3.13; no paid compute or model calls were used.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • Relevant new and existing unit tests pass locally with my changes.
  • I have tested the change through the public runner end-to-end.
  • There are no dependent downstream changes.

Additional context

Prepared with assistance from OpenAI Codex. This is a console verbosity fix, not a claim that debug output is a security boundary. Verbose mode intentionally continues to display the existing thought text.

Keep thought text out of run_debug's final-response display while preserving
verbose output and all parts in returned events.

Assisted-by: OpenAI Codex
copybara-service Bot pushed a commit that referenced this pull request Oct 8, 2026
Merge #7452

print_event() and Runner.run_debug() now skip Part(thought=True) text when verbose=False instead of printing it alongside the final response.

PiperOrigin-RevId: 995933316
@adk-bot

adk-bot commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Thank you @BlueRaddish for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit 53cb763.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Oct 8, 2026
@adk-bot adk-bot closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged [Status] This PR is merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants