Commit graph

39084 commits

Author SHA1 Message Date
Ishaan Jaff
4479944d35
fix(cloud-agents): index worker_jwt_hash to avoid full scans (Greptile P2)
LIT-2890 / B2's long-poll heartbeat calls find_worker_by_jwt on every
request, which filters by worker_jwt_hash. Without an index that's a
full table scan per heartbeat once the worker pool grows past a handful
of rows. Adding the index now so it lands with the table create rather
than as a follow-up migration during B2 ramp-up.
2026-05-06 15:31:50 -07:00
Ishaan Jaff
efcdbee010
test(cloud-agents): _resolve_proxy_url honors trust boundaries
Covers all four resolution paths and the security-critical default:

  * LITELLM_CLOUD_AGENT_PROXY_BASE_URL wins regardless of forwarded
    headers (and trailing slashes get stripped).
  * X-Forwarded-Host is IGNORED unless LITELLM_TRUST_PROXY_HEADERS=1.
    A forged header pointing at attacker.example must not show up.
  * Trust-flag opt-in honors X-Forwarded-Host + X-Forwarded-Proto,
    but x-forwarded-proto alone (no host) doesn't poison the response.
  * Last-resort fallback to localhost:4000 when no Host header.
2026-05-06 15:31:42 -07:00
Ishaan Jaff
6a0f04c8f3
fix(cloud-agents): stop trusting X-Forwarded-Host in install URL (Greptile P1)
Resolution order for the URL embedded in the install one-liner is now:

  1. LITELLM_CLOUD_AGENT_PROXY_BASE_URL env var (operator-configured,
     fully trusted) — recommended for production.
  2. X-Forwarded-Host / X-Forwarded-Proto, ONLY when the operator
     opts in via LITELLM_TRUST_PROXY_HEADERS=1.
  3. The request's direct Host header — safe by default because it
     reflects the actual TCP destination, not an attacker-supplied hop.

Previously any authenticated caller could forge X-Forwarded-Host to
embed an attacker-controlled URL in the install command. If a second
operator ran that command, the worker would send its raw pair token to
the attacker's host, who could then call POST /v2/agent-workers/register
and gain a long-lived worker JWT.

Also adds structured logging on /register failures (invalid / replayed
/ expired tokens) so operators running the proxy behind a WAF / fail2ban
can detect abuse at the network layer (the proxy itself doesn't ship a
built-in per-IP limiter).
2026-05-06 15:31:35 -07:00
Ishaan Jaff
0a942c2ed8
test(cloud-agents): _aws_mock_enabled defaults off and only "1" enables it
Locks the production-safe default for LITELLM_CLOUD_AGENT_MOCK_AWS so a
future revert to the unsafe "1" default trips CI. Also covers the
strict-string parsing — typos like "true" / "yes" must NOT silently
flip on the mock.
2026-05-06 15:31:22 -07:00
Ishaan Jaff
a9cd1fc764
fix(cloud-agents): default LITELLM_CLOUD_AGENT_MOCK_AWS to off (Greptile P1)
Previously the test-connection endpoint defaulted to mock-on, so a fresh
production proxy would silently return a synthetic success for any
non-empty AWS access key. Operators saving incorrect credentials would
only discover the failure later when VMs failed to launch.

Default is now "0" — operators must set LITELLM_CLOUD_AGENT_MOCK_AWS=1
explicitly to opt into the mock path during local development.

Also adds an inline comment on _build_update_payload's `is not None`
guard so a future contributor doesn't silently drop `False` / `0`
updates by switching to truthy comparison.
2026-05-06 15:31:17 -07:00
Ishaan Jaff
793e769bd5
test(cloud-agents): pin shell-quoting behavior for install command
Adds three regression cases that fail if a future change drops the
shlex.quote() pass on proxy_url, raw_token, or install_script_url. The
existing simple-input cases still pass unchanged because shlex.quote
returns alnum/colon/slash/dot strings verbatim.
2026-05-06 15:31:08 -07:00
Ishaan Jaff
e4cce78b6e
fix(cloud-agents): shell-quote install command interpolations (Greptile P1)
shlex.quote() the install_script_url, proxy_url, and raw_token before
interpolating into the curl-pipe-sh one-liner. Without quoting, a
proxy_url containing spaces or shell metacharacters (e.g. via a misconfig
or the X-Forwarded-Host issue Greptile also flagged) could produce a
malformed or exploitable command on the worker box.
2026-05-06 15:31:02 -07:00
ishaan-berri
c15718f9d1
Fix Anthropic streaming reasoning token usage (#27319)
* fix anthropic streaming reasoning token usage

Co-authored-by: ishaan-berri <ishaan-berri@users.noreply.github.com>

* test anthropic streaming reasoning usage end to end

Co-authored-by: ishaan-berri <ishaan-berri@users.noreply.github.com>

* address anthropic reasoning token text split

Co-authored-by: ishaan-berri <ishaan-berri@users.noreply.github.com>

* harden anthropic reasoning usage for mocked tokens

Co-authored-by: ishaan-berri <ishaan-berri@users.noreply.github.com>

---------

Co-authored-by: oss-agent-shin <279349115+oss-agent-shin@users.noreply.github.com>
Co-authored-by: ishaan-berri <ishaan-berri@users.noreply.github.com>
2026-05-06 15:28:22 -07:00
ishaan-berri
bd1a05aed9
Fix MCP DB reload partial failures (#27314)
* Fix MCP database reload partial failures

Co-authored-by: ishaan-berri <ishaan-berri@users.noreply.github.com>

* Avoid staged MCP registry exposure

Co-authored-by: ishaan-berri <ishaan-berri@users.noreply.github.com>

---------

Co-authored-by: oss-agent-shin <279349115+oss-agent-shin@users.noreply.github.com>
Co-authored-by: ishaan-berri <ishaan-berri@users.noreply.github.com>
2026-05-06 15:18:18 -07:00
ishaan-berri
924c141843
Add new chat model metadata (#27313)
* add new model metadata

Co-authored-by: ishaan-berri <ishaan-berri@users.noreply.github.com>

* address review feedback

Co-authored-by: ishaan-berri <ishaan-berri@users.noreply.github.com>

---------

Co-authored-by: oss-agent-shin <279349115+oss-agent-shin@users.noreply.github.com>
Co-authored-by: ishaan-berri <ishaan-berri@users.noreply.github.com>
2026-05-06 15:15:21 -07:00
Ishaan Jaffer
45b1336115
test(cloud-agents): write-only secret invariants (LIT-2891 validation #2) 2026-05-06 15:14:22 -07:00
Ishaan Jaffer
d384bb757f
test(cloud-agents): pair token + worker JWT helper tests (LIT-2891 validation #5) 2026-05-06 15:14:22 -07:00
Ishaan Jaffer
2c3b4fd397
test(cloud-agents): scope filter unit tests (LIT-2891 validation #3) 2026-05-06 15:14:15 -07:00
Ishaan Jaffer
6ae896ac40
test(cloud-agents): scaffold agent_settings_endpoints test package 2026-05-06 15:14:15 -07:00
Ishaan Jaffer
f6e5951556
test(agent_session_endpoints): validate cleanup sweeper for expiry/dead-daemon/stuck-runs (LIT-2877 #13) 2026-05-06 15:10:37 -07:00
Ishaan Jaffer
6a815d2b1f
test(agent_session_endpoints): validate JWT scope/exp/cross-session/terminated rejection (LIT-2877 #12) 2026-05-06 15:10:35 -07:00
Ishaan Jaffer
306df1aecc
test(agent_session_endpoints): validate cascade delete + provider.terminate (LIT-2877 #11) 2026-05-06 15:10:34 -07:00
Ishaan Jaffer
5e93b44177
test(agent_session_endpoints): validate cross-tenant isolation at all 3 levels (LIT-2877 #10) 2026-05-06 15:10:32 -07:00
Ishaan Jaffer
3f60ae6a90
test(agent_session_endpoints): validate session + run idempotency (LIT-2877 #9) 2026-05-06 15:10:31 -07:00
Ishaan Jaffer
1b481e4949
test(agent_session_endpoints): validate SSE resume + Last-Event-ID header (LIT-2877 #8) 2026-05-06 15:10:29 -07:00
Ishaan Jaffer
8feafae5b9
test(agent_session_endpoints): validate concurrent run-create returns 409 run_busy (LIT-2877 #7) 2026-05-06 15:10:28 -07:00
Ishaan Jaffer
42d8fdb741
test(agent_session_endpoints): validate /followup smart inject vs new-run (LIT-2877 #6) 2026-05-06 15:10:26 -07:00
Ishaan Jaffer
1567c00c20
test(agent_session_endpoints): validate run state transitions + cancel (LIT-2877 #5) 2026-05-06 15:10:25 -07:00
Ishaan Jaffer
a271a73276
test(agent_session_endpoints): validate session state transitions (LIT-2877 #4) 2026-05-06 15:10:23 -07:00
Ishaan Jaffer
46266b1dd3
test(agent_session_endpoints): validate agent reused across sessions (LIT-2877 #3) 2026-05-06 15:10:22 -07:00
Ishaan Jaffer
1801c1cf15
test(agent_session_endpoints): add in-memory Prisma fake + multi-tenant TestClient fixtures 2026-05-06 15:10:21 -07:00
Ishaan Jaffer
b483dbe7e9
test(agent_session_endpoints): add package marker 2026-05-06 15:10:19 -07:00
Ishaan Jaffer
3c4065b36c
feat(cloud-agents): wire vm-config/secrets/workers/pool-status routers in proxy_server 2026-05-06 15:08:18 -07:00
Ishaan Jaffer
430a39bbfd
feat(cloud-agents): add /v2/agent-vm-pool/status stub (real impl owned by LIT-2890) 2026-05-06 15:08:14 -07:00
Ishaan Jaffer
fd3b3637ac
feat(cloud-agents): add /v2/agent-workers register/list/revoke endpoints 2026-05-06 15:06:37 -07:00
Ishaan Jaffer
75ef38573a
feat(cloud-agents): add /v2/agent-secrets CRUD endpoints (write-only values) 2026-05-06 15:05:44 -07:00
Ishaan Jaffer
266081ff30
feat(proxy): mount /v2/agents+sessions routers + start cleanup sweeper 2026-05-06 15:03:25 -07:00
Ishaan Jaffer
68d11f445f
feat(agent_session_endpoints): add cleanup sweeper for expired sessions, dead daemons, stuck runs 2026-05-06 15:03:24 -07:00
Ishaan Jaffer
d8c66623ee
feat(agent_session_endpoints): add daemon callbacks (register/heartbeat/next-run/events:append) 2026-05-06 15:03:22 -07:00
Ishaan Jaffer
6ee24a5cbc
feat(agent_session_endpoints): add /v2/sessions/{sid}/runs CRUD + SSE + cancel 2026-05-06 15:03:21 -07:00
Ishaan Jaffer
bca9abeaef
feat(agent_session_endpoints): add module init exposing routers 2026-05-06 15:03:19 -07:00
Ishaan Jaffer
c3f9c5565e
feat(cloud-agents): add /v2/agent-vm-config GET/PUT and test-connection endpoints 2026-05-06 15:01:22 -07:00
Ishaan Jaffer
5bdb533a4d
feat(cloud-agents): add single-use pair token issuer/consumer for self-hosted worker install 2026-05-06 15:01:17 -07:00
Ishaan Jaffer
5ab785c90c
feat(cloud-agents): add per-repo scope filter for agent secrets (LIT-2891 validation #3) 2026-05-06 15:01:12 -07:00
Ishaan Jaffer
6923e08366
feat(cloud-agents): add thin nacl SecretBox wrapper for agent settings AWS creds + secrets 2026-05-06 15:01:07 -07:00
Ishaan Jaffer
4b921faa01
feat(cloud-agents): add Pydantic request/response models for agent settings endpoints 2026-05-06 15:01:03 -07:00
Ishaan Jaffer
c90d4525aa
feat(cloud-agents): add agent_settings_endpoints package init 2026-05-06 15:00:59 -07:00
Ishaan Jaffer
22d23835dd
feat(cloud-agents): add CLOUD_AGENT_* constants for pair token TTL and warm-pool cost estimate 2026-05-06 15:00:55 -07:00
Ishaan Jaffer
8655092d50
feat(cloud-agents): add Prisma migration for AgentVMConfig/Secret/Worker tables 2026-05-06 15:00:50 -07:00
Ishaan Jaffer
469fae0bb5
feat(cloud-agents): mirror new agent settings models in litellm-proxy-extras schema.prisma 2026-05-06 15:00:46 -07:00
Ishaan Jaffer
6cb9849cfd
feat(cloud-agents): mirror new agent settings models in litellm/proxy/schema.prisma 2026-05-06 15:00:33 -07:00
Ishaan Jaffer
ae1c5e5638
feat(cloud-agents): add LiteLLM_AgentVMConfig/Secret/Worker models to root schema.prisma 2026-05-06 15:00:30 -07:00
Ishaan Jaffer
f69ac9e029
feat(agent_session_endpoints): add /v2/agents CRUD endpoints 2026-05-06 14:59:53 -07:00
Ishaan Jaffer
996427ae70
feat(agent_session_endpoints): add /v2/sessions CRUD + followup + conversation 2026-05-06 14:59:52 -07:00
Ishaan Jaffer
e892489aa7
feat(agent_session_endpoints): add Prisma row to response serialization 2026-05-06 14:59:50 -07:00