Skip to content

Conversation

@copybara-service
Copy link

@copybara-service copybara-service bot commented Jan 22, 2026

feat: Improving LoggingPlugin

This CL refactors and improves the LoggingPlugin in the ADK core.

Here's a summary of the changes:

  1. Consistent Agent Name Logging: The plugin now consistently retrieves the agent name from callbackContext.agentName() in beforeAgentCallback and afterAgentCallback, instead of using agent.name().

  2. Enhanced LLM Response Logging: The formatContent method has been significantly updated to provide more detailed logging for different types of Content.parts() within an LLM response. It now explicitly logs:

    • Trimmed and potentially truncated text.
    • The name of functionCall and functionResponse.
    • Indicators for codeExecutionResult and other part types.
      The different parts are joined by " | ".
  3. Improved Optional Field Logging: Optional fields like llmResponse.errorMessage() and toolContext.functionCallId() are now always logged, displaying "None" when the optional is empty, rather than only logging when the value is present.

  4. Simplified Argument Formatting: The formatArgs method now uses args.toString() for formatting, simplifying the code while still handling truncation for long argument strings.

  5. Removed Redundant Error Logging: Duplicate logger.error calls within onLlmError and onToolError have been removed, as the preceding log calls already capture the necessary error information.

  6. Test Updates: LoggingPluginTest.java has been updated to mock mockCallbackContext.invocationContext() and remove an unnecessary mock for mockCallbackContext.branch().

@copybara-service copybara-service bot force-pushed the test_859569830 branch 3 times, most recently from 7933d22 to 1978ed5 Compare January 22, 2026 15:50
@copybara-service copybara-service bot closed this Jan 22, 2026
@copybara-service copybara-service bot deleted the test_859569830 branch January 22, 2026 16:02
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.

0 participants