Skip to content

litellm terminal noise: quiet as a default, and the no-fetch stamp on every lane - #473

Merged
rejojer merged 7 commits into
mainfrom
fix/litellm-quiet-defaults
Sep 3, 2026
Merged

litellm terminal noise: quiet as a default, and the no-fetch stamp on every lane#473
rejojer merged 7 commits into
mainfrom
fix/litellm-quiet-defaults

Conversation

@rejojer

@rejojer rejojer commented Sep 3, 2026

Copy link
Copy Markdown
Member

Lands the litellm terminal-noise follow-ups reviewed on fix/litellm-warning (review view: #458). Seven commits, cherry-picked onto current main.

What changes

The banner switch flips where the lookup happens. _openai_agent asks LiteLLM which provider serves a model twice before building the model, and openai_agent_config asks with no model built at all. A failed lookup print()s the red "Provider List:" banner into stdout, mid-answer. _quiet_litellm() now runs at both get_llm_provider call sites, so every lane is covered.

Quieting litellm's loggers is a default, not a clamp. _quiet_litellm() used to set the four litellm loggers to ERROR on every call, overriding whatever the host application, litellm._turn_on_debug(), or LITELLM_LOG=DEBUG had set. It now sets a level only while a logger is still NOTSET. Unset stays ERROR as before; anything set explicitly wins, and there is no per-call setLevel churn.

The no-fetch default covers every lane. LITELLM_LOCAL_MODEL_COST_MAP moved from the client's preload to utils' module scope. The CLI pipeline and openai_agent_config/anthropic_runner_config on a managed cloud client never run that preload, so they fetched litellm's model cost map over the network on first import, and printed a warning when offline. run_pageindex.py no longer needs its own copy of the stamp.

The thinking-budget ceiling stopped outrunning the stamp. _default_max_tokens, reached from anthropic_runner_config and messages(), imported litellm with no utils on its import path. On a managed cloud client that meant a remote cost-map fetch, measured at 3517 entries against the bundled 2982.

LITELLM_LOG=ERROR is no longer stamped into the environment. It pinned litellm's stderr handler at ERROR for the whole process, disabling litellm._turn_on_debug() for good, while the logger level was what actually gated the chatter. Output verified identical with and without it across plain, logging-configured, and debug hosts.

The retry notice only fires when a retry follows (an off-by-one inherited from the old print).

Verification

  • 481 tests pass; the without-frameworks leg passes.
  • Every public surface that can reach litellm was checked in a fresh process for whether pageindex.utils was loaded before litellm's first import: managed-cloud and own-model openai_agent_config and anthropic_runner_config, the chat lane's model and protocol lookups, the thinking-budget ceiling, CLI token counting, and run_pageindex.py offline. All report the local cost map. The remaining managed-cloud surfaces never import litellm at all.
  • New assertions were red-verified against the pre-change code.
  • An explicit LITELLM_LOCAL_MODEL_COST_MAP wins from both the shell and .env.
  • Malformed LITELLM_LOG values raise exactly as they did before.

https://claude.ai/code/session_01CrSg9uRBvzVujNyU25Wmgk

…them

_openai_agent asks litellm which provider serves a model twice
(_openai_protocol, _cache_extra_args) before _openai_model flips
suppress_debug_info, and openai_agent_config's litellm/ branch never
flipped it at all; a managed cloud client runs no preload, so each
failed lookup still print()ed the "Provider List:" banner. Quiet at the
two get_llm_provider call sites instead, which covers every lane.

Also: LITELLM_LOG at ERROR or above now clamps to that level (CRITICAL
used to skip the clamp and end up noisier than unset); the retry notice
is logged only when a retry follows; test_preload_stamps_litellm_log_level
no longer leaks LITELLM_LOG=ERROR into the session; the config-time
repair test covers _quiet_litellm with the preload thread pinned off.

Claude-Session: https://claude.ai/code/session_01Gq5Kwi7wEgQNVT4k1XUhq9
…s itself now

Since 30652ca each get_llm_provider caller and every completion helper
flips the banner switch and clamps litellm's logger before touching
litellm, so the background import's own _quiet_litellm() had no path
left that depended on it; it was also the one place that mutated
process-global logging at a moment the caller could not predict. The
env stamps stay: import-time records still need them. The config-time
repair test no longer needs the preload guard pinned.

Claude-Session: https://claude.ai/code/session_01Gq5Kwi7wEgQNVT4k1XUhq9
… covers every lane

_quiet_litellm() set litellm's loggers to ERROR on every entry, overriding whatever the host, litellm._turn_on_debug(), or LITELLM_LOG=DEBUG had set. It now sets a level only while a logger is still NOTSET: the default stays ERROR, anything set explicitly wins, and there is no per-call setLevel churn.

LITELLM_LOCAL_MODEL_COST_MAP moves from the client's preload to utils' import. The CLI pipeline and openai_agent_config on a cloud client import litellm without the preload and fetched the remote model map on first use (offline: a WARNING). Every litellm lane imports utils first.

The LITELLM_LOG=ERROR stamp is gone: it pinned litellm's stderr handler at ERROR for the whole process (silencing _turn_on_debug for good) while the logger level was what actually gated the chatter — output verified identical with and without it across plain, logging-configured, and debug hosts.

Claude-Session: https://claude.ai/code/session_01CrSg9uRBvzVujNyU25Wmgk
_default_max_tokens is reached from anthropic_runner_config/messages(). On a managed cloud client the constructor never imports pageindex.utils, and local_chat deliberately keeps utils off its import path, so that lane imported litellm with LITELLM_LOCAL_MODEL_COST_MAP unset: the model cost map was fetched over the network (3517 entries vs the bundled 2982) and offline printed the very warning this branch removes. Verified end to end through the public API, before and after.

Claude-Session: https://claude.ai/code/session_01CrSg9uRBvzVujNyU25Wmgk
@rejojer
rejojer merged commit 0400366 into main Sep 3, 2026
9 checks passed
@rejojer
rejojer deleted the fix/litellm-quiet-defaults branch September 3, 2026 10:37
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.

1 participant