chore(py): Reduce noisy logging in python SDK - #5853
Conversation
There was a problem hiding this comment.
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.
| detail = str(e).replace('\n', ' ') | ||
| if len(detail) > 180: | ||
| detail = detail[:177] + '...' |
There was a problem hiding this comment.
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
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. Plainuv runscripts had the same payload spam, and “raise the log level” didn’t work.Here's what we did:
genkit startterminal by default (message-first logs, muted httpx/otel/google-genai/uvicorn access).GENKIT_LOG=debug|info|warn|erroropt-in for internals.