Skip to content

fix(cli): hide thought parts from adk run output - #8103

Open
prassu017 wants to merge 1 commit into
google:mainfrom
prassu017:fix-8102-cli-hide-thoughts
Open

prassu017 wants to merge 1 commit into
google:mainfrom
prassu017:fix-8102-cli-hide-thoughts

Conversation

@prassu017

Copy link
Copy Markdown

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Problem:
The human-readable printers in cli.py (_print_event for adk run, and run_input_file for adk run --replay) join the text of every part in an event. LiteLlm maps a reasoning model's thinking / reasoning_content to Part(text=..., thought=True), so the reasoning is printed glued to the answer: [assistant]: <thought text><final answer>.

Solution:
Skip parts with thought=True in both printers, so only the answer is shown. JSONL output (--jsonl) is unchanged and still carries the thought parts. Showing thoughts separately behind a flag, which the issue also mentions, is left out.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

New test_print_event_hides_thought_parts and test_run_input_file_hides_thought_parts. On main (9620b42) both fail, e.g. assert ['[agent]: thinking...Hi!'] == ['[agent]: Hi!']; with the fix:

pytest tests/unittests/cli/utils/test_cli.py
37 passed

The test file's fake Part classes gained a thought attribute, which the real types.Part always has. test_cli_tools_click.py has the same 27 failures with and without this change (optional deps such as sqlalchemy not installed in my environment). The full suite and tox were not run. pyink --check and isort --check-only pass on both files (Python 3.13).

Manual End-to-End (E2E) Tests:

Not run (no local Ollama). The unit tests feed the printers an event with a thought part and an answer part.

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.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

AI-assisted; tests run locally.

`adk run` and `--replay` joined every text part of an event, so a
thinking model's reasoning (e.g. Ollama `thinking` mapped to
`thought=True` by LiteLlm) was printed glued to the answer.

Fixes google#8102
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.

displays Ollama/Qwen3 thought text as part of the final answer

2 participants