Skip to content

Conversation

@ammmr
Copy link
Contributor

@ammmr ammmr commented Aug 19, 2025

Reason for this change:

Currently, the detailed llm_request object is logged at the info level when connecting to the live API. This causes two main issues:

  1. Excessive log output with large instructions: When instructions are large, the unstructured log output becomes problematic. Since the logs are not structured, any
    newline characters in the instruction content cause each line to be output as a separate log entry, resulting in massive log output that floods the logging system.
  2. Unnecessary verbosity in production: The detailed request information is primarily useful for debugging purposes and should not appear in standard info-level logs,
    especially when connections are established frequently.

Changes made:

  • Changed logger.info to logger.debug in src/google/adk/models/google_llm.py at line 294 for the live connection logging statement.

Impact:

This change will:

  • Reduce log noise in production environments where info-level logging is enabled
  • Keep the detailed connection information available when debug-level logging is needed for troubleshooting
  • Improve log readability by showing only essential information at the info level

Before:
logger.info('Connecting to live with llm_request:%s', llm_request)

After:
logger.debug('Connecting to live with llm_request:%s', llm_request)

This is a non-breaking change that only affects logging verbosity.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @ammmr, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request aims to reduce excessive logging verbosity in production environments by adjusting the log level for live connection requests. Previously, detailed llm_request objects were logged at the info level, leading to unnecessary noise. The change reclassifies this specific log entry to the debug level, ensuring that detailed connection information is still available for debugging purposes without cluttering standard operational logs. This improves log readability and maintainability without impacting functionality.

Highlights

  • Log Level Adjustment: Changed the logging level for llm_request objects during live API connections from info to debug.
  • Production Log Reduction: This change significantly reduces log noise in production environments by moving detailed, debug-specific information out of standard info-level logs.
  • Debugging Information Retention: The detailed llm_request information remains accessible for troubleshooting when debug-level logging is enabled.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@adk-bot adk-bot added bot triaged live [Component] This issue is related to live, voice and video chat labels Aug 19, 2025
@adk-bot adk-bot requested a review from hangfei August 19, 2025 08:24
@adk-bot
Copy link
Collaborator

adk-bot commented Aug 19, 2025

Response from ADK Triaging Agent

Hello @ammmr, thank you for creating this PR!

Could you please add a testing plan section to your PR description to describe how you tested this change? This will help reviewers to review your PR more efficiently.

Thanks!

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly addresses the issue of excessive log verbosity by changing the log level for live connection requests from info to debug. My review focuses on improving the consistency and safety of this logging. I've suggested using an existing helper function to format the debug log message, which prevents logging large data blobs and aligns with practices elsewhere in the file. I also recommended adding a concise info-level log to maintain essential observability for this operation.

)
llm_request.live_connect_config.tools = llm_request.config.tools
logger.info('Connecting to live with llm_request:%s', llm_request)
logger.debug('Connecting to live with llm_request:%s', llm_request)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While changing the log level to debug is a good step to reduce verbosity, the current implementation directly logs the llm_request object. This can still lead to very large log entries, especially if the request contains inline data (e.g., images), and is inconsistent with how requests are logged elsewhere in this file.

For consistency and to avoid logging potentially large data blobs, I suggest using the existing _build_request_log helper function, which is designed to create a safe and readable representation of the request. This function excludes raw byte data from logs.

Additionally, for better observability, you might consider adding a concise info-level log message that summarizes the connection attempt, similar to what's done in generate_content_async (lines 112-114). This would provide essential information in production logs without the excessive detail.

Here's a suggested implementation:

    logger.info('Connecting to live for model: %s', llm_request.model)
    logger.debug('Live connection request details: %s', _build_request_log(llm_request))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the background of why this log was added, but I assume it's intended to output connection information and similar details.
⁠_build_request_log appears to be a function designed to output ⁠contents and ⁠instruction, so I don't think it aligns with the intended purpose.

@hangfei
Copy link
Collaborator

hangfei commented Aug 21, 2025

@ammmr thanks. the change make sense. But i think we can add another a short log at logger.log level.

@ammmr
Copy link
Contributor Author

ammmr commented Aug 21, 2025

@hangfei

#2600 (comment)

Thank you for the review! I appreciate your feedback.

Just to clarify your suggestion - do you mean adding a brief info-level log message (e.g., just showing the model name or connection status) while keeping the detailed
llm_request object at debug level?

For example, something like:
logger.info('Connecting to live with model: %s', llm_request.model) # Brief info
logger.debug('Connecting to live with llm_request:%s', llm_request) # Detailed debug

This way we could maintain visibility of connection events in production logs without the verbosity issue. Is this what you had in mind?

copybara-service bot pushed a commit that referenced this pull request Nov 7, 2025
Merge #2600

**Reason for this change:**

Currently, the detailed llm_request object is logged at the info level when connecting to the live API. This causes two main issues:

  1. Excessive log output with large instructions: When instructions are large, the unstructured log output becomes problematic. Since the logs are not structured, any
  newline characters in the instruction content cause each line to be output as a separate log entry, resulting in massive log output that floods the logging system.
  2. Unnecessary verbosity in production: The detailed request information is primarily useful for debugging purposes and should not appear in standard info-level logs,
  especially when connections are established frequently.

  **Changes made:**

  - Changed logger.info to logger.debug in src/google/adk/models/google_llm.py at line 294 for the live connection logging statement.

  **Impact:**

  This change will:
  - Reduce log noise in production environments where info-level logging is enabled
  - Keep the detailed connection information available when debug-level logging is needed for troubleshooting
  - Improve log readability by showing only essential information at the info level

  **Before:**
  logger.info('Connecting to live with llm_request:%s', llm_request)

  **After:**
  logger.debug('Connecting to live with llm_request:%s', llm_request)

  This is a non-breaking change that only affects logging verbosity.

Co-authored-by: Hangfei Lin <hangfei@google.com>
COPYBARA_INTEGRATE_REVIEW=#2600 from ammmr:ammmr-info-to-debug-connect-log 36eab15
PiperOrigin-RevId: 829596092
@adk-bot
Copy link
Collaborator

adk-bot commented Nov 7, 2025

Thank you @ammmr for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit 42d4c4e.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot closed this Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

live [Component] This issue is related to live, voice and video chat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants