Fix: route the last two core/src console.error calls through the shared logger - #826
Open
AmaadMartin wants to merge 2 commits into
Open
Fix: route the last two core/src console.error calls through the shared logger#826AmaadMartin wants to merge 2 commits into
AmaadMartin wants to merge 2 commits into
Conversation
added 2 commits
August 8, 2026 15:00
…logger The compactor and LoadMemoryTool wrote their failure diagnostics with console.error, so a consumer who calls setLogger() or setLogLevel() could not silence or redirect them. Both sites now use the shared logger facade. The 'ERROR in ' prefix is dropped because the logger already renders the level: keeping it produced 'ERROR: [ADK] ... ERROR in LoadMemoryTool ...'.
The Logger API is variadic, so passing the error keeps the Error object intact for a custom logger installed via setLogger(); a template literal flattened it to a string before the logger saw it. This also matches the dominant call shape in the repo (runner.ts, a2a_remote_agent.ts). The load-memory test now builds a real Context over an InvocationContext whose memoryService rejects, so it exercises Context.searchMemory and drops the 'as unknown as Context' cast.
AmaadMartin
pushed a commit
that referenced
this pull request
Aug 12, 2026
…through the shared logger
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
N/A
Problem: Two sites in
core/srcwrite their failure diagnostics withconsole.error: the summarizer catch inagent_controlled_context_compactor.tsand therunAsynccatch inload_memory_tool.ts. A consumer who callssetLogger(),setLogger(null)orsetLogLevel()cannot silence or redirect either line. The records also miss theADKlabel, level and timestamp that every other ADK diagnostic carries.Solution: Both sites now call
logger.errorfromcore/src/utils/logger.ts, so only the identifier changes. I used theloggerfacade rather than a module-levelconst logger = getLogger(), because the facade readscurrentLoggerat call time and so still honours a latersetLogger(). The caught error stays a second argument, which keeps theErrorobject intact for a custom logger. Behaviour is otherwise unchanged: the compactor still swallows the error and clears its flags, andLoadMemoryToolstill rethrows.The
ERROR inprefix in the load-memory message is dropped because the logger already renders the level, so keeping it producedERROR: [ADK] <ts> ERROR in LoadMemoryTool runAsync: ....Collision check: I listed the 400 open PRs on this fork and searched every non-
maincommit for edits to these two files and to the two message strings. Four PRs changecore/src/utils/logger.ts(#807, #795, #697, #683) and two touch other parts of the compactor (refactor/compaction-utils,feat/apply-rewinds-live-event-filter). None converts these two call sites, so this branches frommain.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.
One new test per changed statement. Existing tests are untouched.
core/test/context/agent_controlled_context_compactor_test.ts— "logs the summarizer failure"core/test/tools/load_memory_tool_test.ts— "logs the failure before rethrowing"Both spy on
getLogger().error, which the facade forwards to, and both assert on the sameErrorinstance the code under test threw. The load-memory test builds a realContextover anInvocationContextwhosememoryServicerejects, so it drives the realContext.searchMemorypath.Proof each test can fail. I restored the original
console.errorline and re-ran the matching test:AssertionError: expected "error" to be called with arguments: [ 'Compaction failed:', …(1) ] / Number of calls: 0AssertionError: expected "error" to be called with arguments: [ …(2) ] / Number of calls: 0Commands run on the pushed commit:
Manual End-to-End (E2E) Tests:
Call
setLogger(null)from@google/adk, then driveLoadMemoryTool.runAsyncinto its catch with a memory service that rejects. Before this change a bare line prints on the console. After it, nothing prints.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.