Fix: make -v/--verbose an honest --log_level debug shortcut on every command - #700
Open
AmaadMartin wants to merge 2 commits into
Open
Conversation
added 2 commits
August 5, 2026 22:30
The CLI advertises -v/--verbose on seven commands and honours it on none of them. web, api_server and run let --verbose outrank an explicitly supplied --log_level, and the two deploy actions plus integration conformance never read the flag at all. resolveLogLevelName() is now the single place that decides the level. It upgrades to debug only while --log_level sits at its default, which is the rule adk-python applies through ParameterSource.DEFAULT. The five action handlers that resolve a level take the leaf Command that commander already passes them, and integration conformance now calls setLogLevel at all. The extra handler parameter makes prettier re-wrap five action signatures, so most of the cli.ts diff is re-indentation: `git diff -w` shows the real change.
Commander applies an implied value only while the target option sits at
its default source, which is the same rule the hand-rolled
resolveLogLevelName() applied through getOptionValueSource(). Declaring
`.implies({log_level: 'debug'})` on the shared VERBOSE_OPTION drops the
helper, the `command: Command` parameter that every action handler had
to take, and the re-indentation that parameter forced on five handler
bodies.
The tests are unchanged and still pass: they assert the resolved level,
not how it is resolved.
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.
Stacked on #592 (
fix/cli-log-level-choices-validation), which supplies the??fallback this fix needs. Review that one first; this PR targets its branch.Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
Link to an existing issue (if applicable):
N/A
Or, if no issue exists, describe the change:
Problem: The CLI advertises
-v/--verboseon seven commands and honours it on none of them. Onweb,api_serverandrunthe flag outranks an explicitly supplied--log_level, soadk web --log_level error --verboseruns at DEBUG. Ondeploy cloud_run,deploy agent_engine,deploy reasoning_engineandintegration conformancethe flag is parsed and dropped, soadk deploy cloud_run --verbosestill bakes--log_level='info'into the image and sends--verbosity infoto gcloud.Solution:
VERBOSE_OPTIONnow declares.implies({log_level: 'debug'}). Commander applies an implied value only while the target option sits at its default source, so--verbosefills indebugand an explicitly supplied level always wins, in either flag order. That is the rule adk-python gets fromParameterSource.DEFAULT. Every command that registers the shared option inherits it, so the deploy handlers keep readingoptions['log_level']and now receivedebug.integration conformancecallssetLogLevelfor the first time, and the help text states the shortcut and the precedence rule.Notes for the reviewer:
getLogLevelFromOptionsno longer readsverbose, so it shrinks to one line. Thecli.tsdiff is +12/-16.-v, --verbose [boolean]flag spec. Fix: stop boolean CLI flags from swallowing the [agents_dir] operand #693 converts these into real flags.gh pr list --repo AmaadMartin/adk-js --state open --limit 1000. Fix: honour --otel_to_cloud false on the web, api_server and run commands #695, Fix: stop boolean CLI flags from swallowing the [agents_dir] operand #693 and Fix: do not bind an unknown flag to the optional [agents_dir] positional #585 also editcli.ts, but none of them touches the verbose or log-level resolution. No open PR lands this change.Testing Plan
Please describe the tests that you ran to verify your changes. This is required for all PRs that are not small documentation or typo fixes.
Unit Tests:
[x] I have added or updated unit tests for my change.
[x] All unit tests pass locally.
npx vitest run --project unit:dev dev/test/cli/cli_test.ts— 89 passed, 22 of them new. The new block covers every surface: precedence onwebin both flag orders, an explicit level that equals the default,api_server,run, both deploy paths,integration conformance, and the help text of all seven commands.Proof the tests can fail. I ran the new tests against seven mutations.
.implies({log_level: 'debug'})deletedexpected { logLevel: 'info' } to match { logLevel: 'debug' }fordeploy cloud_run --verbosegetLogLevelFromOptionsshort-circuits onverboseagainexpected "spy" to be called with [3], received [0]forweb --log_level error --verbose??changed back to||in the level lookupweb --log_level debug --verbosereports INFO instead of DEBUGsetLogLevelcall removed fromintegration conformanceNumber of calls: 0options['verbose'] ? 'debug' : ...in the deploy handlersdeploy agent_engine --log_level=warn --verbosereportsdebug--log_leveldefault flipped todebugdeploy cloud_runwith no flags reportsdebug--verbosehelp text restoredEvery new test dies under at least one mutation.
Coverage.
cli.tsmeasures 97.13% lines and 77.27% branches. Every line of the new code runs. Two branch arms do not: the?? 'info'and the pre-existing?? LogLevel.INFOingetLogLevelFromOptions.--log_levelcarries a.default('info')on every command that registers it, so argv cannot reach either fallback. The other uncovered lines are thecatchblocks in the action handlers, which this change does not touch. I added no new throw sites.Manual End-to-End (E2E) Tests:
Please provide instructions on how to manually test your changes, including any necessary setup or configuration.
Run
npm run buildfirst. I put a stubgcloudonPATHthat records its arguments and copies the generated Dockerfile, because the real deploy deletes its temp folder in afinallyblock.node dev/dist/esm/cli_entrypoint.js deploy cloud_run --verbose --temp_folder <dir> --project <p> --region <r> ./my-agentgcloud receives
--verbosity debug, and the Dockerfile ends withCMD npx adk api_server /app/agents/my-agent --port=8000 --host=0.0.0.0 --log_level=debug. Before this change both readinfo.--log_level warn --verbosegives--verbosity warnand--log_level=warn. With neither flag it givesinfo.node dev/dist/esm/cli_entrypoint.js integration conformance --helpprintsOptional. Enable verbose (DEBUG) logging. Shortcut for --log_level debug; an explicitly passed --log_level wins.The
web,api_serverandrunsurfaces pass the resolved level tosetLogLevel, which the unit tests assert. I could not observe the level from the terminal, because ADK writes its DEBUG lines during a model-backed agent run.CI does not run on this PR: the workflow triggers on
pull_request: branches: [main]and this PR targets the stacked base. Local validation on the pushed commit:npm run build,npx eslint "dev/**/*.ts"andnpx prettier "dev/**/*.ts" --checkall pass.npm run ts:checkreports 296 errors incore/testandtests/, identical with and without this change and none indev/; CI does not run it.Checklist
[x] I have read the CONTRIBUTING.md document.
[x] I have performed a self-review of my own code.
[x] I have commented my code, particularly in hard-to-understand areas.
[x] I have added tests that prove my fix is effective or that my feature works.
[x] New and existing unit tests pass locally with my changes.