Skip to content

chore(py): Reduce noisy logging in python SDK - #5853

Draft
huangjeff5 wants to merge 1 commit into
mainfrom
jh-quiet-terminal
Draft

chore(py): Reduce noisy logging in python SDK#5853
huangjeff5 wants to merge 1 commit into
mainfrom
jh-quiet-terminal

Conversation

@huangjeff5

@huangjeff5 huangjeff5 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Under genkit start, the Python process shares one TTY with the CLI. Before this change that stream was a dump — health polls, telemetry failures, playground errors, and full model payloads — so you couldn’t tell whether your app was healthy. Plain uv run scripts had the same payload spam, and “raise the log level” didn’t work.

Here's what we did:

  • Quiet shared genkit start terminal by default (message-first logs, muted httpx/otel/google-genai/uvicorn access).
  • GENKIT_LOG=debug|info|warn|error opt-in for internals.
  • Plugin init failures: one short Error line; reflection stays up.
  • Telemetry export failures best-effort (debug only).
  • Playground action failures: stack on Dev UI wire, not terminal spam.
  • Structlog INFO floor so plain scripts don't dump generate payloads by default.

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

Copy link
Copy Markdown
Contributor

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 improves the terminal logging experience in Genkit, particularly in development mode (GENKIT_ENV=dev). It introduces a structured logging configuration that silences noisy third-party libraries, formats console output cleanly, and moves verbose tracebacks and lifecycle messages from INFO or WARNING to DEBUG level. Additionally, it updates error handling to return stack traces only in development environments and includes tests for this behavior. Feedback is provided regarding extracting the error message truncation logic in _registry.py into a reusable helper method to reduce duplication.

Comment on lines +455 to +457
detail = str(e).replace('\n', ' ')
if len(detail) > 180:
detail = detail[:177] + '...'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This logic for truncating error details is also used in _trigger_lazy_loading (lines 555-557), although with a different length limit. To avoid code duplication and improve maintainability, consider extracting this into a private helper method. For example:

def _truncate_error_detail(self, error: Exception, max_len: int) -> str:
    detail = str(error).replace('\n', ' ')
    if len(detail) > max_len:
        return detail[:max_len - 3] + '...'
    return detail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant