Fix: route AgentFile.load multiple-apps/agents warnings through AdkLogger - #457
Open
AmaadMartin wants to merge 1 commit into
Open
Fix: route AgentFile.load multiple-apps/agents warnings through AdkLogger#457AmaadMartin wants to merge 1 commit into
AmaadMartin wants to merge 1 commit into
Conversation
…AdkLogger The two "Multiple apps/agents found" diagnostics in AgentFile.load() called console.warn directly while every other diagnostic in agent_loader.ts goes through the module-level AdkLogger. As a result they printed without the AgentLoader label and without colorization, and - the actual defect - they ignored AdkLogger.setLogLevel(), so they could not be silenced when every neighbouring warning could. Route both through the existing module logger. The message text is unchanged character for character. Tests: the multiple-agents test now spies on AdkLogger.prototype.warn instead of console.warn (the assertion it replaced pinned the bypass being removed), and the previously untested multiple-apps branch gains a sibling test.
This was referenced Aug 2, 2026
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
Link to an existing issue (if applicable):
N/A — no existing issue.
Or, if no issue exists, describe the change:
Problem:
dev/src/utils/agent_loader.tsowns a module-level ADK CLI logger (const logger = new AdkLogger({label: 'AgentLoader', colorize: {all: true}}), line 29), and every diagnostic in the module goes through it —logger.warnat line 223,logger.infoat line 410,logger.warnat lines 418/420 — except the two warnings emitted insideAgentFile.load(), which calledconsole.warndirectly. Three concrete consequences:No
AgentLoaderlabel.AdkLoggerapplieswinston.format.label({label: 'AgentLoader'})(dev/src/utils/logger.ts:41-44); these two lines printed bare, so a user could not tell which CLI subsystem produced them.No colorization. The logger is built with
colorize: {all: true}(dev/src/utils/logger.ts:51-53), so every siblingAgentLoadermessage is colorized and these two were not.Not silenceable — the real defect.
AdkLogger.warn()early-returns whenthis.logLevel > LogLevel.WARN(dev/src/utils/logger.ts:104-110) andAdkLogger.setLogLevel()is how the CLI raises that threshold.console.warnignores the gate, so these two messages could not be suppressed by any log-level setting while every neighbouring diagnostic could.Solution: Route both call sites through the existing module-level
logger(2 changed lines). No new logger instance, no constructor injection, no new import —loggerwas already in scope.Consoletransport viaAdkLoggerrather than throughconsole.warndirectly. That is the point of the change — it makes them match the file's other diagnostics — and no test asserts which stream (stdout vs stderr) receives them.console.*calls elsewhere indev/src(there is nono-consolelint rule, so this is not a repo-wide sweep), theAgentLoader.loadAgentFrom{File,Directory}catch blocks, anddev/src/utils/logger.tsitself (no transport/level/format changes).Why one existing assertion changed. The repo guideline is add a new test, do not rewrite an existing one. The single exception applies here:
'loads first agent if multiple agents exported'spied onconsole.warn, i.e. it pinned the exact bypass this PR removes, so it could not survive unmodified. The edit is confined to the spy target (vi.spyOn(console, 'warn')->vi.spyOn(AdkLogger.prototype, 'warn')) and its two references; the fixture, the esbuild mock and theexpect(agent.name).toEqual('agent1')assertion are untouched. No test was deleted, skipped or weakened.Collision check (open PRs on this fork).
gh pr list --repo AmaadMartin/adk-js --state open --limit 100was reviewed before writing any code. Three PRs are plausibly adjacent:fix/log-skipped-agent-fileslogger.warnto theAgentFileLoadingErrorcatch blocks (lines ~515/540) and appends tests at the end of the file; this PR touches lines 254/281 and theAgentFiledescribe block. The only shared line is the identicalimport {AdkLogger} from '../../src/utils/logger.js';addition. Verified empirically rather than assumed: a localgit mergeof the two branches auto-merged with no conflict, and the merged tree runs green (33 tests). Branched frommainon that basis instead of stacking.feat/logger-get-log-levelcore/src/utils/logger.tsagent_loader.ts.feat/shared-level-gated-winston-loggerdev/src/utils/logger.tsAdkLogger.warnsurface this PR calls; no overlap withagent_loader.ts.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.
'loads first agent if multiple agents exported'— covers therootAgents.length > 1branch (line 281). Updated because its assertion targetedconsole.warn, the sink this PR replaces.'loads first app if multiple apps exported'— covers therootApps.length > 1branch (line 254), which had no test at all before this PR. It asserts the exact rendered message, plusisApp(loaded), the selected app name and its root agent.Coverage of the new code is 100% (2/2 statements, 2/2 branches), read out of the v8 report rather than eyeballed:
(The whole-file number for
agent_loader.tsunder this one test file is 84.04% lines / 84% branches; that is pre-existing and unrelated to these two lines.)Proof the new tests can fail (mutation testing). Each changed line was reverted to
console.warnin turn and the corresponding test was re-run:console.warn->FAIL dev/test/utils/agent_loader_test.ts > AgentLoader > AgentFile > loads first agent if multiple agents exportedAssertionError: expected "warn" to be called with arguments: [ StringContaining{…} ] Number of calls: 0console.warn->FAIL dev/test/utils/agent_loader_test.ts > AgentLoader > AgentFile > loads first app if multiple apps exportedAssertionError: expected "warn" to be called with arguments: [ Array(1) ] Number of calls: 0Both were then restored and the file re-run green (31/31).
Repo gates on the pushed commit:
npm run ts:checkis red repo-wide onmaintoday (pre-existing errors acrosscore/test/**andtests/integration/**, the subject of several separate open PRs). Filtering its output for the two files this PR touches returns zero errors.Manual End-to-End (E2E) Tests:
Please provide instructions on how to manually test your changes, including any necessary setup or configuration.
npm install && npm run buildLlmAgentinstances under names other thanrootAgent, and with no default export:adk web <dir>oradk run <dir>).Multiple agents found in <path>. Using the agent1 as a root agent.now renders with the sameAgentLoaderlabel and coloring as the loader's other messages (e.g.Detected change in <file>, reloading agents...), and that the wording is unchanged.Appinstances (names other thanapp/rootApp, no default export) and confirmMultiple apps found in ...behaves identically.WARNand confirm both lines are now suppressed along with the loader's other warnings — before this change they printed regardless.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.