Back to Agent Zero

litellm_transport.py DOX

helpers/litellm_transport.py.dox.md

2.02.0 KB
Original Source

litellm_transport.py DOX

Purpose

  • Own Agent Zero's LiteLLM transport adapter for Chat Completions and Responses API calls.
  • Normalize Agent Zero model-call kwargs into provider-safe LiteLLM requests.
  • Preserve canonical response metadata for history, provider-state continuation, and fallback decisions.

Ownership

  • litellm_transport.py owns the runtime implementation.
  • litellm_transport.py.dox.md owns durable notes about responsibilities, contracts, side effects, and verification for that implementation.
  • Classes:
  • TransportMode
  • TransportRecovery
  • TransportPolicy
  • LiteLLMTransport
  • ChatCompletionsTransport
  • ResponsesTransport
  • ResponsesEventParser
  • Top-level functions include transport cache reset, request normalization, parsing, prompt-cache preparation, and response/error classifiers.

Runtime Contracts

  • Keep provider selection and provider-specific defaults outside this helper; callers pass a resolved LiteLLM model name and kwargs.
  • Strip Agent Zero internal kwargs before sending requests to LiteLLM.
  • Do not send orphan tool controls when no tools are present; strict OpenAI-compatible servers can reject empty tools arrays.
  • Prefer Responses API when configured, but fallback to Chat Completions when the provider does not support Responses.
  • Preserve provider-state metadata when Responses API calls succeed, and fall back to local replay when provider state is unsupported.
  • Keep prompt-cache markers only for providers that accept them.

Work Guidance

  • Add provider-agnostic request cleanup here when multiple OpenAI-compatible providers can benefit.
  • Treat fallback behavior as a shared transport contract, not a provider registry.
  • Keep tool conversion symmetric between Chat Completions and Responses requests.

Verification

  • Run pytest tests/test_stream_tool_early_stop.py tests/test_responses_architecture.py -q after changing transport normalization or fallback behavior.
  • Run local-provider smoke checks when changing OpenAI-compatible request cleanup.

Child DOX Index

No child DOX files.