Commit Graph

31 Commits

Author SHA1 Message Date
Sameer Kankute 7dbf09cb12 Fix all 130126 tests 2026-01-14 17:47:03 +05:30
Ishaan Jaff ab50fea663 [Fix] turn_off_message_logging Does Not Redact Request Messages in proxy_server_request Field When Stored to Database (#18897)
* update _get_proxy_server_request_for_spend_logs_payload

* test_spend_logs_redacts_request_and_response_when_turn_off_message_logging_enabled
2026-01-10 11:28:21 -08:00
Sameer Kankute b6e011309a Fix: test_spend_logs_payload_success_log_with_router 2026-01-08 16:07:00 +05:30
Alexsander Hamir d2f2fe1be5 [Fix] CI/CD - litellm_mapped_tests_proxy (#18572) 2026-01-01 15:27:51 -08:00
yuneng-jiang fc80a92971 Add Error code filter on UI 2025-12-22 20:15:01 -08:00
yuneng-jiang a510654736 Allow Error code filtering on spend logs endpoint 2025-12-22 17:46:25 -08:00
yuneng-jiang 74842de78e Adding backend 2025-12-19 13:04:59 -08:00
yuneng-jiang b0d371d864 delete route for cloudzero 2025-12-17 22:12:31 -08:00
yuneng-jiang 0e5b56eddf Fixing tests 2025-12-16 12:51:44 -08:00
yuneng-jiang 66306f21b1 Add litellm overhead to spend logs metadata 2025-12-15 20:56:55 -08:00
Alexsander Hamir e9baa83a0f [Fix] CI/CD – Clean Up Performance PR Changes & others (#17838) 2025-12-11 12:50:03 -08:00
Ishaan Jaff 059fedbed5 [Feat] Agent Gateway - Track agent_id in SpendLogs (#17795)
* add agent_id in metadata in spend logs

* add agent_id in SpendLogsPayload

* add agent_id in SpendLogsPayload

* add _set_agent_id_on_logging_obj

* add agent id tracking in SpendLogs

* add agent id in spend logs

* fix create_a2a_client

* test_asend_message_passes_agent_id_to_callback

* test_get_logging_payload_includes_agent_id_from_kwargs

* test_asend_message_streaming_triggers_callbacks

* fix asend_message_streaming

* asend_message_streaming

* A2AStreamingIterator

* _handle_stream_message

* test_asend_message_streaming_propagates_metadata
2025-12-10 16:09:56 -08:00
Kristian Brünn 63fae79493 fix(sql): Optimize SpendLogs queries to use timestamp filtering for index usage (#17504)
* fix: optimize SpendLogs queries to use timestamp filtering (#17487)

* use timestamptz & enhance test
2025-12-04 21:52:57 -08:00
yuneng-jiang 6029a24baa Merge remote-tracking branch 'origin' into litellm_org_usage 2025-11-20 20:19:16 -08:00
Alexsander Hamir 2e007505da fix(spend-logs): trim logged response strings (#16654)
* fix(spend-logs): trim logged response strings

- route spend-log responses through the existing string sanitizer so oversized base64/text fields are truncated before persistence
- add unit tests covering the truncation path and the feature flag

Note: embeddings-specific truncation (numeric vectors) is still pending and will be handled separately.

* remove unnecessary comment

* add: sanitization unit test for embeddings

* fix: simplify sanatization logic

I overcomplicated a simple change for lack of understanding, fixed.
2025-11-18 20:12:49 -08:00
yuneng-jiang 3d2552be9f Fixed failing tests 2025-11-15 16:31:37 -08:00
Ishaan Jaffer abe3fcc7e7 test_ui_view_spend_logs_with_team_id 2025-11-15 10:12:47 -08:00
yuneng-jiang 379aa7b79a Pagination for /spend/logs/session/ui endpoint (#16603) 2025-11-13 22:03:00 -08:00
yuneng-jiang 8bf491c939 [Fix] /spend/logs/ui Access Control (#16446)
* RBAC for /spend/logs/ui

* Addressing comments
2025-11-12 18:44:21 -08:00
Alan Ponnachan df33f36c06 Correctly handle date filters in /spend/logs endpoint (#16443) 2025-11-10 19:26:55 -08:00
Ishaan Jaff 8140d85d28 [Bug Fix] - LiteLLM Usage shows key_hash- (#16471)
* test_get_logging_payload_api_key_preserved_when_standard_logging_payload_is_none

* fix get_logging_payload

* test_api_key_preserved_through_failure_hook_to_database
2025-11-10 18:15:52 -08:00
YutaSaito 8b33328cc1 Perf speed up pytest (#15951)
* perf: Skip sleep delays in base_mail.py during tests to improve test speed

* perf: Mock datetime.now in parallel_request_limiter_v3.py to improve test speed

* pref: Mock urllib system calls in test_aiohttp_transport.py to improve test speed

* chore: add --durations=50 to visualize slowest tests

* pref: reduce setup phase overhead by widening fixture scope in conftest.py

* test: stabilize flaky tests

* fix: minor issue
2025-10-27 19:43:40 -07:00
Ishaan Jaffer 4b876ea9ca test_sanitize_request_body_for_spend_logs_payload_mixed_types 2025-09-20 12:33:37 -07:00
Ishaan Jaffer ed5c9f1c69 test fixes for mapped tests 2025-09-19 18:01:36 -07:00
Burt Holzman e9e548d797 Fix provider budgets 2025-09-11 12:08:43 -05:00
mubashir1osmani d9bbbc10a6 added tests 2025-09-07 10:17:28 -04:00
Ishaan Jaff 4d941c914e [Feat] Responses API Session Handling - Multi media support (#13347)
* rename ResponsesSessionHandler

* use ResponsesSessionHandler

* test session handler

* refactor ResponsesSessionHandler

* fix get_proxy_server_request_from_spend_log

* use constant for LITELLM_TRUNCATED_PAYLOAD_FIELD

* add _should_check_cold_storage_for_full_payload

* add get_class_type_for_custom_logger_name

* get_active_custom_logger_for_callback_name

* add get_proxy_server_request_from_cold_storage to CustomLogger

* add ColdStorageHandler

* start using cold storage integration

* add get_proxy_server_request_from_cold_storage

* fixes from manual testing

* s3 v2 fix getting region name

* ChatCompletionImageUrlObject

* use _get_configured_cold_storage_custom_logger

* fixes for _should_check_cold_storage_for_full_payload

* fix _download_object_from_s3

* test_s3_v2_with_cold_storage

* add cold_storage_object_key to StandardLoggingMetadata

* use get_proxy_server_request_from_cold_storage_with_object_key

* add cold_storage_object_key to SpendLogsMetadata

* add cold_storage_object_key

* get_proxy_server_request_from_cold_storage_with_object_key

* use get_proxy_server_request_from_cold_storage_with_object_key

* test responses API

* add get_proxy_server_request_from_cold_storage_with_object_key

* session handler fixes

* test session handler

* fix ruff checks

* _download_object_from_s3

* cleanup

* test

* lint fix

* test_e2e_cold_storage_successful_retrieval

* test_e2e_generate_cold_storage_object_key_successful

* test_async_gcs_pub_sub_v1

* test fix

* test fix

* test fix

* test_standard_logging_metadata_has_cold_storage_object_key_field

* test_sanitize_request_body_for_spend_logs_payload_basic

* test_transform_input_image_item_to_image_item_with_image_data
2025-08-07 10:59:53 -07:00
Cole McIntosh 79e4d77bcf fix: Handle circular references in spend tracking metadata JSON serialization (#12643)
* fix: Handle circular references in spend tracking metadata JSON serialization

- Fixes issue #12634 where circular references in metadata caused
  ValueError: Circular reference detected when logging spend data
- Adds _safe_json_dumps() function that detects and handles circular
  references by replacing them with placeholder strings
- Maintains full functionality for normal objects while preventing
  crashes from circular references
- Adds comprehensive tests for circular reference handling
- Critical fix for v1.74.3 stable release

* fix: Replace bare except clauses with specific Exception handling

- Fixes E722 linting errors in _safe_json_dumps function
- Maintains same error handling behavior while following best practices
- All tests continue to pass

* refactor: Use existing safe_dumps utility instead of custom implementation

- Replace custom _safe_json_dumps() with existing safe_dumps() from litellm_core_utils
- Remove duplicate code and leverage existing circular reference handling
- Update tests to use safe_dumps function
- Maintains same functionality while reducing code duplication
- All tests continue to pass
2025-07-16 07:24:41 -07:00
Krish Dholakia c4af2eb5e2 MCP - usage tracking (#12397)
* fix(common_daily_activity.py): initial commit with working mock BE endpoint for mcp usage

* feat(ui/): show mcp server activity on UI

allows admin to know which mcp's are being used

* feat(common_daily_activity.py): return activity by key

* feat(ui/): show top api keys for a given model / mcp server

allow user to know which key is driving spend

* fix(common_daily_activity.py): use known mcp server names

* feat(server.py): log the namespaced tool name (includes server prefix)

allow accurate cost tracking

* feat(db_spend_update_writer.py): log by mcp_namespaced_tool_name

store aggregate daily activity by mcp_namespaced_tool_name

Enables cost / usage tracking by mcp tool name

* fix(server.py): add key/user metadata to mcp calls

* refactor(common_daily_activity.py): update to return mcp activity in API

* fix(common_daily_activity.py): handle empty key

* fix(common_daily_activity.py): track when api key is empty

* test(test_spend_management_endpoints.py): update tests

* fix: fix ui linting error

* fix: fix linting errors

* test: add missing key

* build(schema.prisma): add mcp tool tracking

* fix(migration.sql): add schema migration file

* feat(server.py): add request logging for mcp calls

enables storing the mcp calls

* fix(new_usage.tsx): fix linting errors

* fix: fix code qa errors

* fix(activity_metrics.tsx): fix ui linting errors post-merge

* fix(types/utils.py): fix linting error

* fix(server.py): always have name
2025-07-08 22:08:16 -07:00
Cole McIntosh e1fbdde289 Fix boto3 tracer wrapping for observability (#11869)
* feat: add summarize parameter to /spend/logs endpoint for individual transaction logs

- Introduced a new `summarize` parameter to control data format when querying spend logs.
- `summarize=true` (default) returns aggregated data, while `summarize=false` provides individual transaction logs.
- Updated documentation and added tests to validate the new functionality.

* fix: wrap boto3.Session() with tracer for observability - Add tracer.trace wrapper around boto3.Session() call in _get_aws_region_name method - Ensures all boto3 initializations in base_aws_llm.py are properly instrumented - Fixes test_boto3_init_tracer_wrapping test failure - Maintains consistency with other boto3 calls in the same file
2025-06-18 15:47:55 -07:00
Krish Dholakia ef42461c1e Litellm fix GitHub action testing (#11163)
* test: add __init__.py files

* refactor: rename test folder to avoid naming conflict

* test: update workflows

* test: update tests

* test: update imports

* test: update tests

* test: remove unused import

* ci(test-litellm.yml): add pytest retry to github workflow

* test: fix test
2025-05-26 14:41:42 -07:00