Commit graph

39020 commits

Author SHA1 Message Date
Ishaan Jaffer
da2dbbb3a9
test(v2 managed agents): add runnable QA happy-path script (Flow 1/2/3) 2026-05-07 11:09:12 -07:00
Ishaan Jaffer
6500a4b5d8
test(v2 managed agents): adapter tests for model object split, stateful streaming, permission auto-grant
send_message:
  - assert {providerID, modelID} object body (not string)
  - 'openrouter/anthropic/claude-3' splits on first '/' only
  - models without '/' omit the field entirely
  - model=None omits the field

list_messages: assert {info, parts} envelopes normalize to MessageRow,
  with reasoning/step-start/step-finish filtered out of content and the
  combined providerID/modelID showing up as our model string.

stream_events: assert text deltas route through partID -> type tracking,
  the partID map persists across multiple message.part.updated events,
  session.idle is enriched with the tracked assistant message_id, and
  permission.asked triggers a fire-and-forget POST to
  /session/:sid/permissions/:per_id with {response:'once'}.
2026-05-07 10:48:36 -07:00
Ishaan Jaffer
56b6da5a2f
test(v2 managed agents): update normalization tests for real opencode wire shapes
Update fixtures to use the {info, parts} envelope, epoch-ms timestamps,
camelCase wire field names (providerID/modelID), and the message.part.delta
event shape. Add coverage for:
  - filtering step-start/step-finish/reasoning parts out of content
  - tool state.status branches (running/completed/error/pending)
  - the part_types map populated by message.part.updated
  - message.part.delta routing via part_types lookup (text vs reasoning,
    unknown partID drops)
  - message.updated -> message.completed when info.time.completed is set
  - session.error unwrapping the nested error.data.message string
  - server.heartbeat / session.created drop to None
2026-05-07 10:48:29 -07:00
Ishaan Jaffer
a00695114f
fix(v2 managed agents): opencode adapter — model object split, stateful events, permission auto-grant
send_message: opencode 1.14.41 rejects string-form model with 400; split
our '<provider>/<model>' on the first '/' into the {providerID, modelID}
object form. Omit the field entirely if there's no '/' so opencode falls
back to its default agent/model.

stream_events: maintain a per-stream partID -> type map populated from
message.part.updated events so message.part.delta events can be routed
to text/reasoning. Track the in-flight assistant message_id from
message.updated so session.idle events (which carry only sessionID in
real opencode) can be enriched before yielding message.completed.

permission gating: opencode emits permission.asked events that block
tool calls until granted. Auto-grant via fire-and-forget
POST /session/:sid/permissions/:per_id body {response:'once'} so MVP
tool calls don't hang. Will surface as a real event type once we expose
permission gating to v2 callers.
2026-05-07 10:48:20 -07:00
Ishaan Jaffer
fec3ca1436
fix(v2 managed agents): rewrite opencode normalization for real wire shapes
opencode messages are nested as {info, parts}, not flat. Field naming on
the wire is camelCase with capital-ID suffix (sessionID, messageID,
partID, callID, providerID, modelID). Timestamps are epoch ms ints.
Part types include text/reasoning/tool/step-start/step-finish — only
text parts go into content; only tool parts go into tools. Tool I/O
lives under part.state.input / part.state.output (or .error).

Streaming text deltas come via message.part.delta events with
{messageID, partID, field, delta} — the part type is NOT on the delta
event, so normalize_opencode_event now takes a part_types dict the
caller maintains across the stream. session.idle has no messageID in
real opencode payloads — emit message.completed with message_id=None
and let the adapter enrich it from tracked state. session.error
unwraps the nested error.data.message string.
2026-05-07 10:48:09 -07:00
Ishaan Jaffer
520c55cf8f
fix(v2 managed agents): add SandboxSpec validator tests
Cover idle_timeout_minutes <= timeout_minutes contract \xc2\xa76.2 invariant plus
existing timeout_minutes [1, 1440] bound. New test_types.py keeps typing
concerns separate from endpoint tests in test_agents.py.
2026-05-07 10:43:08 -07:00
Ishaan Jaffer
49fd3ed1ba
fix(v2 managed agents): enforce idle_timeout_minutes <= timeout_minutes on SandboxSpec
Per contract \xc2\xa76.2, idle_timeout_minutes must be in [1, timeout_minutes].
Previously only ge=1 was enforced, so idle=1440 with timeout=10 would pass.

Add a Pydantic v2 model_validator(mode="after") that raises ValueError when
idle_timeout_minutes > timeout_minutes; FastAPI surfaces it as a 422.
2026-05-07 10:43:03 -07:00
Ishaan Jaffer
cf454e38c2
fix(v2 managed agents): wire up sessions/messages/events sub-routers 2026-05-07 10:07:54 -07:00
Ishaan Jaffer
63fd2fb91c
test(v2 managed agents): three happy-path integration tests (Flow 1/2/3) 2026-05-07 10:06:56 -07:00
Ishaan Jaffer
440211e54e
test(v2 managed agents): pytest fixtures (opencode lifecycle, fake row, app client) 2026-05-07 10:06:56 -07:00
Ishaan Jaffer
22a8d86e02
test(v2 managed agents): unit tests for SSE events endpoint 2026-05-07 10:06:56 -07:00
Ishaan Jaffer
e4432be886
test(v2 managed agents): unit tests for messages endpoints 2026-05-07 10:06:56 -07:00
Ishaan Jaffer
0016942ce1
test(v2 managed agents): unit tests for GET /v2/sessions/:id 2026-05-07 10:06:56 -07:00
Ishaan Jaffer
af4c6de05e
test(v2 managed agents): unit tests for POST /v2/agents 2026-05-07 10:06:56 -07:00
Ishaan Jaffer
3da6049a9f
test(v2 managed agents): unit tests for OpencodeAdapter (respx-mocked) 2026-05-07 10:06:56 -07:00
Ishaan Jaffer
f0272f65bb
test(v2 managed agents): unit tests for opencode normalization 2026-05-07 10:06:56 -07:00
Ishaan Jaffer
adb6361746
test(v2 managed agents): adapter tests package init 2026-05-07 10:06:56 -07:00
Ishaan Jaffer
def252a64d
test(v2 managed agents): tests package init 2026-05-07 10:06:56 -07:00
Ishaan Jaffer
e22212e306
feat(v2 managed agents): register managed_agents_router in proxy_server 2026-05-07 10:06:56 -07:00
Ishaan Jaffer
e4e6d79d73
feat(v2 managed agents): aggregate endpoint routers 2026-05-07 10:06:55 -07:00
Ishaan Jaffer
111728915e
feat(v2 managed agents): add GET /v2/sessions/:id/events SSE handler 2026-05-07 10:06:55 -07:00
Ishaan Jaffer
c530197518
feat(v2 managed agents): add POST + GET /v2/sessions/:id/messages handlers 2026-05-07 10:06:55 -07:00
Ishaan Jaffer
8f02f6a268
feat(v2 managed agents): add GET /v2/sessions/:id handler 2026-05-07 10:06:55 -07:00
Ishaan Jaffer
30a224f0d0
feat(v2 managed agents): add POST /v2/agents handler 2026-05-07 10:06:55 -07:00
Ishaan Jaffer
3f8aa7ae78
feat(v2 managed agents): add endpoints package init 2026-05-07 10:06:55 -07:00
Ishaan Jaffer
d17a704ca9
feat(v2 managed agents): add adapter registry (sandbox_type -> adapter) 2026-05-07 10:06:55 -07:00
Ishaan Jaffer
9bcea61a3b
feat(v2 managed agents): add OpencodeAdapter (httpx-based) implementation 2026-05-07 10:06:55 -07:00
Ishaan Jaffer
3890b410f9
feat(v2 managed agents): add opencode message + event normalization helpers 2026-05-07 10:06:55 -07:00
Ishaan Jaffer
2b8e11c492
feat(v2 managed agents): add SandboxAdapter Protocol + error types 2026-05-07 10:06:55 -07:00
Ishaan Jaffer
a45f7e85ff
feat(v2 managed agents): add adapters package init 2026-05-07 10:06:55 -07:00
Ishaan Jaffer
6a618c51d3
feat(v2 managed agents): add litellm_api_key masking helper 2026-05-07 10:06:55 -07:00
Ishaan Jaffer
41c484ed97
feat(v2 managed agents): add Prisma DB helpers (insert_agent, get_agent, get_session) 2026-05-07 10:06:55 -07:00
Ishaan Jaffer
d6dbf87ef9
feat(v2 managed agents): add agt_/ses_/msg_ ID prefix helpers 2026-05-07 10:06:55 -07:00
Ishaan Jaffer
40ade8f35f
feat(v2 managed agents): add Pydantic types (Agent, Session, Message, SandboxSpec) 2026-05-07 10:06:55 -07:00
Ishaan Jaffer
317a844216
feat(v2 managed agents): add module skeleton 2026-05-07 10:06:55 -07:00
Ishaan Jaffer
d0c27c1fd5
feat(v2 managed agents): hand-written migration for managed_agent tables 2026-05-07 10:06:55 -07:00
Ishaan Jaffer
071895cd07
feat(v2 managed agents): add ManagedAgent + ManagedAgentSession to extras schema 2026-05-07 10:06:54 -07:00
Ishaan Jaffer
25bee118ff
feat(v2 managed agents): add ManagedAgent + ManagedAgentSession to proxy schema 2026-05-07 10:06:54 -07:00
Ishaan Jaffer
4fb85009d2
feat(v2 managed agents): add ManagedAgent + ManagedAgentSession to root schema 2026-05-07 10:06:54 -07:00
ishaan-berri
fee5900acc
feat(xai): add grok-4.3 and grok-4.3-latest to model_prices_and_conte… (#27154)
* feat(xai): add grok-4.3 and grok-4.3-latest to model_prices_and_context_window.json

xAI's docs page now lists grok-4.3 as the recommended chat / coding model:
"We strongly recommend all API callers use grok-4.3. It is the most
intelligent and fastest model we've built." (https://docs.x.ai/docs/models)

Pricing/specs sourced from xAI's published model metadata:
  - input:  $1.25 / 1M tokens (<=200k),  $2.50 / 1M tokens (>200k)
  - output: $2.50 / 1M tokens (<=200k),  $5.00 / 1M tokens (>200k)
  - cached: $0.20 / 1M tokens (<=200k),  $0.40 / 1M tokens (>200k)
  - context: 1,000,000 tokens
  - capabilities: vision, reasoning, function calling, structured outputs,
    prompt caching, web search

Adds two entries: `xai/grok-4.3` (canonical) and `xai/grok-4.3-latest` (alias),
mirroring the pattern used for the rest of the xAI/Grok-4 family.

* test(xai): add model_info test for grok-4.3 + sync backup cost map

- Mirror xai/grok-4.3 and xai/grok-4.3-latest entries into
  litellm/model_prices_and_context_window_backup.json so the bundled
  model cost map matches the canonical model_prices_and_context_window.json.
- Add tests/test_litellm/test_xai_grok_4_3_model_metadata.py covering
  pricing tiers, capability flags, context window, provider routing,
  and parity between the main and backup cost maps.
- Point 'source' at the live xAI models page (the per-model URL
  https://docs.x.ai/docs/models/grok-4.3 currently 404s).

Co-authored-by: Mateo Wang <mateo-berri@users.noreply.github.com>

---------

Co-authored-by: shin-watcher <shin-watcher@berri.ai>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Mateo Wang <mateo-berri@users.noreply.github.com>
2026-05-07 09:06:56 -07:00
harish-berri
a67b7a7e87
Refactor Bedrock response stream shape handling (#27257)
Some checks are pending
Unit Tests: Caching (Redis) / caching-redis (push) Waiting to run
Unit Tests: Proxy DB Operations / assert-shard-coverage (push) Waiting to run
Unit Tests: Proxy DB Operations / auth-checks (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / budgets (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / custom-logging (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / db-and-spend (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / proxy-runtime (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / endpoints-and-responses (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / guardrails-hooks (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / jwt-and-keys (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / key-generation (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / logging-misc (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / proxy-server-core (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / schema-migration (push) Blocked by required conditions
Unit Tests: Proxy DB Operations / proxy-utils (push) Blocked by required conditions
Unit Tests: Security / security (push) Waiting to run
* Refactor Bedrock response stream shape handling

- Introduced a module-level constant `BEDROCK_RESPONSE_STREAM_SHAPE` to cache the response stream shape, eliminating the need for per-instance caching in `BedrockEventStreamDecoderBase`.
- Updated relevant methods to utilize the new constant, improving performance by avoiding redundant loading of the shape.
- Added tests to ensure the shape is loaded correctly at import time and is consistent across different modules.
- Added a new mock server script for testing Bedrock pass-through functionality.

* Refactor response parsing for Bedrock and SageMaker

- Improved code readability by formatting the parsing method calls in `AWSEventStreamDecoder` for both Bedrock and SageMaker response stream shapes.
- Added blank lines for better separation of code blocks in `invoke_handler.py` and `common_utils.py` to enhance maintainability.

* Enhance error handling for Bedrock and SageMaker response stream shape loading

- Wrapped the loading logic in `_load_bedrock_response_stream_shape` and `_load_sagemaker_response_stream_shape` with try-except blocks to gracefully handle exceptions.
- Added logging to warn when the response stream shape cannot be pre-loaded, ensuring the module imports cleanly.
- Updated tests to verify that loading failures return `None` instead of propagating exceptions.

* Implement error handling for missing response stream shapes in Bedrock and SageMaker

- Added checks in `_parse_message_from_event` methods to raise appropriate errors when `BEDROCK_RESPONSE_STREAM_SHAPE` or `SAGEMAKER_RESPONSE_STREAM_SHAPE` is None, ensuring clearer error reporting.
- Updated logging messages to reflect the unavailability of event-stream decoding for both Bedrock and SageMaker.
- Enhanced unit tests to verify that the correct exceptions are raised when the response stream shapes are not loaded.
2026-05-06 17:39:38 -07:00
ishaan-berri
854456f58e
Fix Prometheus remaining metric zero values (#27348)
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 17:22:20 -07:00
yuneng-jiang
f1c91d754d
[Chore] CI: Block PRs that drop overall code coverage (#27340)
* [Chore] CI: Block PRs that drop overall code coverage

Tighten Codecov project status threshold from 1% to 0% so any drop in
overall project coverage relative to the base commit fails the
codecov/project check. target: auto keeps the bar floating with the
codebase, no manual maintenance needed as coverage moves up over time.

* [Chore] CI: Always post Codecov status regardless of CI outcome

Set codecov.require_ci_to_pass: false and codecov.notify.wait_for_ci:
false so Codecov posts the codecov/project and codecov/patch checks as
soon as the expected uploads arrive, instead of withholding them when
unrelated CI jobs fail. The coverage-regression check is independent
of test pass/fail, and CI failures are already enforced by their own
required-status checks.
2026-05-06 16:41:50 -07:00
yuneng-jiang
a3a42c6c47
[Chore] CI: Assign test_request_size_limit_middleware To Proxy-Runtime Shard (#27341)
The assert-shard-coverage guard in test-unit-proxy-db.yml failed because
test_request_size_limit_middleware.py was added under tests/proxy_unit_tests/
but not referenced by any matrix entry. Assigning it to the proxy-runtime
shard, which already covers other server-runtime tests (proxy_routes,
proxy_gunicorn, server_root_path).
2026-05-06 16:34:45 -07:00
oss-agent-shin
b318231fe9
Add Azure Sentinel audit log support (#27280)
* Add Azure Sentinel audit log callback support

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

* Fix Azure Sentinel audit log batching

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

* Fix Azure Sentinel CI checks

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:50:06 -07:00
ishaan-berri
aba131d3cf
fix: Vertex Anthropic streaming status error hangs (#27310)
* Fix streaming HTTP status error hangs

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

* Fix sync streaming HTTP status error hangs

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

* Cap sync streaming error read workers

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:32:55 -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-berri
487479eff7
perf: cap Prometheus end-user metric cardinality with TTL + LRU eviction (#27272)
Co-authored-by: Yassin Kortam <yassinkortam@g.ucla.edu>
2026-05-06 13:35:13 -07:00