Skip to content

Litellm oss staging 02 14 20262#21307

Merged
Sameerlite merged 20 commits intomainfrom
litellm_oss_staging_02_14_20262
Feb 16, 2026
Merged

Litellm oss staging 02 14 20262#21307
Sameerlite merged 20 commits intomainfrom
litellm_oss_staging_02_14_20262

Conversation

@Sameerlite
Copy link
Collaborator

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Type

🆕 New Feature
🐛 Bug Fix
🧹 Refactoring
📖 Documentation
🚄 Infrastructure
✅ Test

Changes

ephrimstanley and others added 16 commits February 13, 2026 22:18
batch_cost_calculator only checked the global cost map, ignoring
deployment-level custom pricing (input_cost_per_token_batches etc.).
Add optional model_info param through the batch cost chain and pass
it from CheckBatchCost.
The test was creating fresh mocks but not fully isolating from setUp state,
causing intermittent CI failures with 'Expected generation to be called once.
Called 0 times.'

Instead of creating fresh mocks, properly reset the existing setUp mocks to
ensure clean state while maintaining proper mock chain configuration.
Add s3_use_virtual_hosted_style parameter to support AWS S3 virtual-hosted-style URL format (bucket.endpoint/key) alongside the existing path-style format (endpoint/bucket/key).

This enables compatibility with S3-compatible services like MinIO and aligns with AWS S3 official terminology.
#21117)

When a shared ClientSession is passed to LiteLLMAiohttpTransport,
calling aclose() on the transport would close the shared session,
breaking other clients still using it.

Add owns_session parameter (default True for backwards compatibility)
to AiohttpTransport and LiteLLMAiohttpTransport. When a shared session
is provided in http_handler.py, owns_session=False is set to prevent
the transport from closing a session it does not own.

This aligns AiohttpTransport with the ownership pattern already used
in AiohttpHandler (aiohttp_handler.py).
@vercel
Copy link

vercel bot commented Feb 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 16, 2026 1:36pm

Request Review

…issing-standard-logging-object

Managed batches - Misc bug fixes
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 16, 2026

Greptile Summary

This staging PR bundles five independent changes across the codebase:

  • S3 virtual-hosted-style URLs: Adds s3_use_virtual_hosted_style option to S3Logger for S3-compatible services (like MinIO) that require bucket.endpoint/key URL format instead of the default path-style endpoint/bucket/key. Includes docs and comprehensive tests.
  • Anthropic effort="max": Extends effort validation to accept "max" as a valid effort level, gated to Claude Opus 4.6 only. Other models correctly reject this value.
  • Shared aiohttp session fix: Introduces owns_session parameter to AiohttpTransport to prevent closing shared ClientSession instances. When a shared session is reused, owns_session=False is passed so aclose() skips closing it.
  • Duplicate agent spend computation fix: Removes a redundant call to _common_add_spend_log_transaction_to_daily_transaction in add_spend_log_transaction_to_daily_agent_transaction that was computing the daily transaction twice — once before and once after the agent_id null check.
  • Langfuse test isolation: Fixes flaky Langfuse tests by using reset_mock() on shared setUp mocks instead of creating entirely new mock objects that bypassed the test class's mock chain.

All changes include corresponding tests and no critical issues were found.

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk — all changes are well-tested and isolated.
  • Each of the five changes is straightforward with clear intent. The S3 virtual-hosted-style feature adds a new opt-in configuration. The aiohttp session fix and agent spend deduplication address real bugs with targeted tests. The Anthropic effort="max" change is model-gated. Only minor style concerns exist (duplicated URL construction, missing trailing newline). Score is 4 instead of 5 because this is a bundled staging PR covering multiple unrelated changes, which increases review surface area.
  • litellm/integrations/s3_v2.py has duplicated URL construction logic that would benefit from a helper method extraction.

Important Files Changed

Filename Overview
litellm/integrations/s3_v2.py Adds virtual-hosted-style URL support for S3-compatible services. URL construction logic is duplicated 3 times but follows existing pattern. Missing trailing newline at end of file.
litellm/llms/anthropic/chat/transformation.py Adds effort="max" as a valid option for Claude Opus 4.6, with model-gated validation. Clean implementation that correctly reuses existing _is_claude_opus_4_6 helper.
litellm/llms/custom_httpx/aiohttp_transport.py Adds owns_session parameter to prevent closing shared ClientSession instances. Default is True for backward compatibility. Clean implementation.
litellm/llms/custom_httpx/http_handler.py Passes owns_session=False when using shared sessions, correctly wiring the new aiohttp_transport feature.
litellm/proxy/db/db_spend_update_writer.py Removes duplicate _common_add_spend_log_transaction_to_daily_transaction call that was computing the daily transaction twice for agent spend. The common helper is still called once after the agent_id null check.
docs/my-website/docs/proxy/logging.md Documents the new s3_use_virtual_hosted_style configuration option with clear description.
tests/test_litellm/integrations/test_langfuse.py Improves test isolation by using setUp's shared mock objects with reset_mock() instead of creating entirely new mocks, preventing flaky failures from state pollution.
tests/test_litellm/integrations/test_s3_v2.py Comprehensive mock tests for virtual-hosted-style URLs covering async upload, sync upload, download, and protocol variations. No real network calls made.
tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py Adds tests for effort="max" validation for Opus 4.6 and rejection for non-Opus 4.6 models. Good coverage of the new validation logic.
tests/test_litellm/llms/custom_httpx/test_aiohttp_transport.py Adds tests for owns_session behavior: shared sessions not closed, owned sessions closed, and default value is True. Uses real aiohttp sessions but no network calls.
tests/test_litellm/proxy/db/test_db_spend_update_writer.py Adds test verifying the common helper is called exactly once for agent transactions, confirming the duplicate call fix.

Flowchart

flowchart TD
    subgraph S3["S3 URL Construction"]
        A["S3Logger upload/download"] --> B{"s3_endpoint_url set?"}
        B -->|No| C["Default AWS URL: bucket.s3.region.amazonaws.com/key"]
        B -->|Yes| D{"s3_use_virtual_hosted_style?"}
        D -->|True| E["Virtual-hosted: protocol://bucket.endpoint/key"]
        D -->|False| F["Path-style: endpoint/bucket/key"]
    end

    subgraph Aiohttp["Aiohttp Session Management"]
        G["AsyncHTTPHandler"] --> H{"shared_session provided?"}
        H -->|Yes| I["LiteLLMAiohttpTransport\nowns_session=False"]
        H -->|No| J["LiteLLMAiohttpTransport\nowns_session=True"]
        I --> K["aclose() skips session.close()"]
        J --> L["aclose() calls session.close()"]
    end

    subgraph Agent["Agent Spend Transaction"]
        M["add_spend_log_to_daily_agent_txn"] --> N{"agent_id is None?"}
        N -->|Yes| O["Skip - return early"]
        N -->|No| P["_common_add_spend_log...\n(called once)"]
        P --> Q["Queue agent spend update"]
    end
Loading

Last reviewed commit: 72a1bd6

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

11 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 16, 2026

Additional Comments (2)

litellm/integrations/s3_v2.py
Missing trailing newline at end of file

The file no longer ends with a newline character. Most editors and POSIX tools expect text files to end with a newline. This can also cause noise in future diffs.

            return None

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


litellm/integrations/s3_v2.py
URL construction logic is duplicated three times

The virtual-hosted-style and path-style URL construction block is copy-pasted identically at lines 313-326, 474-487, and 575-588. Consider extracting this into a private helper method like _build_s3_url(self, object_key: str) -> str to reduce duplication and make future changes (e.g., trailing-slash handling) easier to maintain.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@Sameerlite Sameerlite merged commit 86a254a into main Feb 16, 2026
38 of 70 checks passed
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.

7 participants