litellm/.github/workflows
devin-ai-integration[bot] ae01882535
feat(proxy): offload spend tracking to a pod-local collector sidecar (#40545)
* feat(proxy): offload spend tracking to a pod-local spend worker sidecar

py-spy on the gateway showed the post-response _PROXY_track_cost_callback,
spend-log and DBSpendUpdateWriter work running on the inference workers'
event loop, so a DB or Redis stall backed up the request path.

When LITELLM_SPEND_WORKER_ENABLED=true, _ProxyDBLogger serializes one compact
typed SpendEvent per success and hands it to a SpendEventProducer that ships
it over a unix socket (default) or loopback-only TCP to a sidecar started as
`python -m gateway.spend_worker`. The sidecar runs the unchanged
_ProxyDBLogger pipeline against the pod's PgBouncer (pooled_database_url).
When the sidecar is unreachable, the buffer is full, or the gateway shuts
down with events still queued or in flight, the producer applies
LITELLM_SPEND_WORKER_ON_UNAVAILABLE (fallback in-process, or drop). The
sidecar half-closes producers on SIGTERM and drains, the producer treats
EOF as unavailable, and the gateway flushes buffered spend counters on
shutdown. The sidecar honors LITELLM_LOG so its writes are visible in its
own process log.

Helm: both charts gain an opt-in spend-worker sidecar container sharing an
emptyDir socket dir, and the componentized chart's HPA uses a
ContainerResource CPU metric scoped to the gateway container so sidecar
CPU does not drive inference scaling.

* feat(terraform): opt-in spend-worker sidecar for the AWS and GCP gateway stacks

Adds spend_worker_* inputs to both modules. On ECS Fargate the sidecar is a second, non-essential container in the gateway task; on Cloud Run it is a second container in the gateway service. Both listen on loopback TCP, share the gateway's DB/Redis/secret env, and set LITELLM_JOB_ROLE=spend_worker. Disabled by default. Plan-only tests cover both, and the terraform CI workflow now runs the gcp module too

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(proxy): retrieve a completed batch in the in-process spend path test

The base now defers cost tracking for batches that are still in flight, so an in_progress batch never reaches update_database

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor(proxy): rename the spend worker sidecar to collector

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): run the collector from the installed litellm package and finish in-flight fallbacks on shutdown

The sidecar command becomes python -m litellm.proxy.collector so the classic image, whose runtime
stage copies only the installed package, can run it. The module now assembles DATABASE_URL and the
pod-local pgbouncer URL itself, replacing gateway/collector.py

The componentized collector sidecar inherits gateway.volumeMounts so custom CA mounts reach it.
SpendEventProducer shields an in-progress fallback from the writer task cancellation so close()
no longer loses an event already handed to the in-process pipeline

Helpers used across modules (address_argument, should_store_prompts_and_responses_in_spend_logs,
flush_spend_counters_on_shutdown) become public so the change adds no reportPrivateUsage errors

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* ci(terraform): drop the gcp job duplicated by the aws/gcp matrix

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(collector): keep metrics env off the classic sidecar and reject shared loopback ports

The classic chart no longer hands PROMETHEUS_METRICS_PORT and the billing metrics env to the collector container, and gives it the same /.npm scratch mount as the proxy on a read-only root. AWS and GCP now refuse a plan where the spend collector and the metrics sidecar bind the same loopback port. A regression test drives a sidecar crash mid-stream on asyncio and uvloop and checks no event is billed by both the sidecar and the in-process fallback; the producer docstring spells out why a failed drain() cannot double count

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* style(proxy): format pooled_database_url after the pgbouncer rebase

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): keep the cache-hit preset key and survive dead producers on collector drain

Cache hits updated the logging object after the early return, so the offloaded spend event carried
preset_cache_key=None and the collector re-hashed reconstructed kwargs. Also guard write_eof() against
producer transports uvloop already closed so one dead connection cannot abort the drain

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(terraform): keep the gcp collector port off the metrics sidecar health port

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): collector connects to Postgres directly under IAM or Entra token auth

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): mark the collector's DATABASE_URL as pooled when it uses the pod's pgbouncer

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: yassin <yassin@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-10 17:14:13 -07:00
..
_test-unit-base.yml feat: move MongoDB vector search to an optional sidecar 2026-09-07 23:02:27 -07:00
auto-close-duplicates.yml fix(ci): stop the auto-close duplicates job colliding with the required test check 2026-09-05 22:26:38 -07:00
auto_update_price_and_context_window.yml chore(ci): close the test-census blind spots and move scripts out of workflows/ (#37586) 2026-08-20 10:07:14 -07:00
check-schema-sync.yml ci: give the remaining pull_request workflows a concurrency group 2026-08-08 03:25:38 +00:00
check-ui-api-types.yml fix(proxy): regenerate lazy OpenAPI snapshot and guard it in CI 2026-08-26 14:32:04 -07:00
check_duplicate_issues.yml fix(ci): close only identical-title duplicates, dry-run the sweep, reopen on reply 2026-08-29 17:30:01 -04:00
ci-coverage.yml feat(ci): assert .github/workflows holds only workflows, correctly named (#37616) 2026-08-20 21:36:26 +00:00
close_low_quality_prs.yml feat(agent-shin): automated PR/issue triage, low-quality auto-close, and review-gate label lifecycle (#30433) 2026-06-17 20:42:27 -07:00
codeql.yml ci(zizmor): gate PRs on medium+ findings and clear existing ones (#30797) 2026-06-18 18:26:03 -07:00
codspeed.yml ci: build the benchmark environment outside the CodSpeed runner (#38426) 2026-08-29 13:58:04 -07:00
conventional-commits.yml ci: give the remaining pull_request workflows a concurrency group 2026-08-08 03:25:38 +00:00
cost-map-guard.yml feat(ci): add the cost map guard check 2026-09-04 17:18:17 -07:00
create-release-branch.yml ci(release): create stable/X.Y.x line branch on X.Y.0 tags (#29457) 2026-06-01 15:56:34 -07:00
create-release.yml fix(release): make Create Release reliable for stable maintenance cuts (#31986) 2026-07-02 16:05:11 -07:00
create_daily_oss_agent_shin_branch.yml fix(ci): make every remaining CI checkout shallow (#35997) 2026-08-05 14:32:17 -07:00
create_daily_staging_branch.yml fix(ci): make every remaining CI checkout shallow (#35997) 2026-08-05 14:32:17 -07:00
e2e_record_replay.yml ci(e2e): record the e2e suite weekly and replay it on weekdays with zero egress (#38163) 2026-08-24 23:49:03 -04:00
guard-fork-dependencies.yml ci: give the remaining pull_request workflows a concurrency group 2026-08-08 03:25:38 +00:00
guard-main-branch.yml chore(ci): retire daily OSS branches in favor of litellm_internal_staging 2026-07-20 11:38:52 -07:00
helm_unit_test.yml ci: give the remaining pull_request workflows a concurrency group 2026-08-08 03:25:38 +00:00
image-scan.yml fix(docker): install bedrock-realtime extra in monolith proxy images (#39223) 2026-09-01 17:51:55 -07:00
issue-keyword-labeler.yml chore: fixes 2026-04-05 01:30:57 -07:00
label-component.yml chore: fixes 2026-04-05 01:30:57 -07:00
mutation-test.yml fix(ci): name the file mutmut actually writes partial results to 2026-08-25 23:54:48 -07:00
osv-scan.yml fix(ci): point OSS contributor workflows to litellm_oss_staging (#31270) 2026-06-24 21:07:59 -07:00
publish-basedpyright-base-counts.yml ci: prepare workflows for main default branch 2026-09-07 12:50:17 -07:00
scorecard.yml chore: fixes 2026-04-05 01:30:57 -07:00
stale.yml chore: fixes 2026-04-05 01:30:57 -07:00
sync-schema.yml chore: fixes 2026-04-05 01:30:57 -07:00
sync-together-ai-models.yml ci: prepare workflows for main default branch 2026-09-07 12:50:17 -07:00
test-code-quality.yml test(ci): guard against two workflow jobs publishing one check-run name 2026-09-05 22:26:09 -07:00
test-e2e-changed.yml ci(e2e): run the access_control canary on harness changes and name failed tests 2026-09-05 18:46:51 -07:00
test-linting.yml ci(lint): gate top-level tests/e2e and litellm files in the diff-scoped lint steps 2026-09-01 22:30:46 -07:00
test-litellm-ui-build.yml ci(ui): run the UI build check through the image's ui-builder stage 2026-09-02 22:09:55 -07:00
test-litellm-ui-lint.yml ci: give the remaining pull_request workflows a concurrency group 2026-08-08 03:25:38 +00:00
test-litellm-ui-unit.yml fix(ui): retain compatible build and test commands 2026-09-08 15:54:13 -07:00
test-mcp.yml ci: measure enterprise/ coverage (#37788) 2026-08-22 22:55:01 -07:00
test-postgres.yml ci: port the Postgres suites off CircleCI onto service containers (#37785) 2026-08-22 22:45:30 -07:00
test-redis-compat.yml fix(redis): coerce env var string types and fix param discovery through decorator wrappers (#30644) 2026-08-31 20:51:31 -07:00
test-rust.yml test(ocr): isolate native Rust bridge contracts (#40410) 2026-09-10 16:51:37 -07:00
test-semgrep.yml fix(ci): retry setup-uv installs to survive transient manifest fetch failures 2026-07-14 14:41:36 -07:00
test-terraform-modules.yml feat(proxy): offload spend tracking to a pod-local collector sidecar (#40545) 2026-09-10 17:14:13 -07:00
test-terraform-provider.yml feat(terraform): coverage-enforcing CI gate against the latest OpenAPI spec (#38710) 2026-08-28 17:11:43 -07:00
test-unit-documentation.yml perf(ci): cache the Rust build the unit shards compile from scratch (#37795) 2026-08-21 20:15:08 -07:00
test-unit-proxy-db.yml feat(ci): guard shard assignment across every sharded test tree (#37593) 2026-08-20 17:30:55 +00:00
test-unit.yml feat(proxy): share database connections across workers with an in-container pgbouncer (#39683) 2026-09-10 22:14:37 +00:00
triage_issue_with_llm.yml feat(agent-shin): automated PR/issue triage, low-quality auto-close, and review-gate label lifecycle (#30433) 2026-06-17 20:42:27 -07:00
triage_reconsider.yml feat(agent-shin): automated PR/issue triage, low-quality auto-close, and review-gate label lifecycle (#30433) 2026-06-17 20:42:27 -07:00
weekly_load_anomaly.yml perf(ci): cache the Rust build the unit shards compile from scratch (#37795) 2026-08-21 20:15:08 -07:00
zizmor.yml ci: run zizmor and proxy-db unit tests on PRs targeting litellm_ branches 2026-07-16 11:44:35 -07:00