Repository navigation
fix: show a readable code language in verbose debug output - #8179
Open
takayoshi-makabe wants to merge 1 commit into
Open
takayoshi-makabe wants to merge 1 commit into
takayoshi-makabe wants to merge 1 commit into
Conversation
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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
Problem: With
Runner.run_debug(verbose=True), the shared event printer formatsExecutableCode.language, atypes.Languageenum, straight into the line. On Python 3.11+ (the minimum ADK supports) this renders the class name, and a part without a language falls back to'code', which doubles the word:The existing unit tests locked in
Executing code code...and only loosely asserted the language line, so neither issue was caught.Solution: Print the enum's value, and show
code (language unknown)when the language is missing orLANGUAGE_UNSPECIFIED.LANGUAGE_UNSPECIFIEDis produced in practice, e.g. by the Interactions API conversion inmodels/interactions_utils.pyfor non-Python code.The change is limited to
print_event()inutils/_debug_output.py, which onlyrun_debuguses.adk runhas its own printer incli/cli.pyand is not affected. Events returned byrun_debugare unchanged.Testing Plan
Unit Tests:
The two existing executable-code tests are replaced by one parameterized test that asserts the exact line for an enum language, a missing language, and
LANGUAGE_UNSPECIFIED.pytest tests/unittests/utils/test_debug_output.py tests/unittests/test_runners.py -k 'print_event or run_debug' -qResult: 21 passed, 242 deselected. On the base revision,
test_debug_output.pyhas 3 failed, 15 passed: all three new cases fail. The full ADK suite was not run.Manual End-to-End (E2E) Tests:
A deterministic
BaseAgentyields three events withexecutable_codeparts:Language.PYTHON, no language, andLANGUAGE_UNSPECIFIED. It runs through the publicInMemoryRunner.run_debug('run', verbose=True)entry point, with no model calls. The output before and after the change is shown above.Script
All repository pre-commit hooks pass on the changed files. Tested on macOS with Python 3.11.4.
Checklist