diff --git a/tests/test_litellm/proxy/agent_session_endpoints/test_agent_reuse.py b/tests/test_litellm/proxy/agent_session_endpoints/test_agent_reuse.py index 50ee3c9cdac..81c62b8b45d 100644 --- a/tests/test_litellm/proxy/agent_session_endpoints/test_agent_reuse.py +++ b/tests/test_litellm/proxy/agent_session_endpoints/test_agent_reuse.py @@ -16,9 +16,9 @@ def _create_agent(client) -> str: def _create_session(client, agent_id: str) -> str: res = client.post( - "/v2/sessions", + f"/v2/agents/{agent_id}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": agent_id, "repos": []}, + json={"repos": []}, ) assert res.status_code == 200, res.text return res.json()["id"] @@ -53,5 +53,5 @@ def test_sessions_under_agent_listed_by_filter(client, noop_provider): headers={"Authorization": "Bearer k"}, ) assert res.status_code == 200 - listed_ids = {s["id"] for s in res.json()["data"]} + listed_ids = {s["id"] for s in res.json()["items"]} assert listed_ids == set(sids) diff --git a/tests/test_litellm/proxy/agent_session_endpoints/test_cascade_delete.py b/tests/test_litellm/proxy/agent_session_endpoints/test_cascade_delete.py index 36f1cd5eacb..a0c0c2e7752 100644 --- a/tests/test_litellm/proxy/agent_session_endpoints/test_cascade_delete.py +++ b/tests/test_litellm/proxy/agent_session_endpoints/test_cascade_delete.py @@ -22,14 +22,14 @@ def test_delete_agent_terminates_sessions_and_calls_provider( aid = agent["id"] sess_a = client.post( - "/v2/sessions", + f"/v2/agents/{aid}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": aid, "repos": []}, + json={"repos": []}, ).json() sess_b = client.post( - "/v2/sessions", + f"/v2/agents/{aid}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": aid, "repos": []}, + json={"repos": []}, ).json() # Create a run on session A so cascade exercises run-cancel path too. @@ -74,18 +74,18 @@ def test_delete_agent_skips_session_already_in_terminal_status( # An "active" session that should still get terminated by the cascade. sess_active = client.post( - "/v2/sessions", + f"/v2/agents/{aid}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": aid, "repos": []}, + json={"repos": []}, ).json() # A session whose status was already flipped to ``error`` (terminal) # but with ``terminated_at`` deliberately left None — the legacy # filter would have re-terminated this row, but the status-based # filter should skip it. sess_already_terminal = client.post( - "/v2/sessions", + f"/v2/agents/{aid}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": aid, "repos": []}, + json={"repos": []}, ).json() terminal_row = next( r @@ -122,9 +122,9 @@ def test_delete_session_terminates_active_runs( json={"name": "t", "model": "gpt-4"}, ).json() sess = client.post( - "/v2/sessions", + f"/v2/agents/{agent["id"]}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": agent["id"], "repos": []}, + json={"repos": []}, ).json() sid = sess["id"] run = client.post( diff --git a/tests/test_litellm/proxy/agent_session_endpoints/test_cleanup_sweeper.py b/tests/test_litellm/proxy/agent_session_endpoints/test_cleanup_sweeper.py index 78d819843e4..dcfa17e4ece 100644 --- a/tests/test_litellm/proxy/agent_session_endpoints/test_cleanup_sweeper.py +++ b/tests/test_litellm/proxy/agent_session_endpoints/test_cleanup_sweeper.py @@ -32,9 +32,9 @@ async def test_sweeper_terminates_expired_sessions( json={"name": "t", "model": "gpt-4"}, ).json() sess = client.post( - "/v2/sessions", + f"/v2/agents/{a["id"]}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": a["id"], "repos": []}, + json={"repos": []}, ).json() sid = sess["id"] @@ -61,9 +61,9 @@ async def test_sweeper_marks_dead_daemon_sessions_error( json={"name": "t", "model": "gpt-4"}, ).json() sess = client.post( - "/v2/sessions", + f"/v2/agents/{a["id"]}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": a["id"], "repos": []}, + json={"repos": []}, ).json() sid = sess["id"] @@ -95,9 +95,9 @@ async def test_sweeper_marks_stuck_runs_error( json={"name": "t", "model": "gpt-4"}, ).json() sess = client.post( - "/v2/sessions", + f"/v2/agents/{a["id"]}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": a["id"], "repos": []}, + json={"repos": []}, ).json() sid = sess["id"] client.post( diff --git a/tests/test_litellm/proxy/agent_session_endpoints/test_concurrent_run_create.py b/tests/test_litellm/proxy/agent_session_endpoints/test_concurrent_run_create.py index df34bd4e52c..245f6ada936 100644 --- a/tests/test_litellm/proxy/agent_session_endpoints/test_concurrent_run_create.py +++ b/tests/test_litellm/proxy/agent_session_endpoints/test_concurrent_run_create.py @@ -21,9 +21,9 @@ def _bootstrap_ready(client, noop_provider): json={"name": "t", "model": "gpt-4"}, ).json() sess = client.post( - "/v2/sessions", + f"/v2/agents/{agent["id"]}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": agent["id"], "repos": []}, + json={"repos": []}, ).json() daemon_token = sess["daemon_token"] sid = sess["id"] diff --git a/tests/test_litellm/proxy/agent_session_endpoints/test_event_append_collision.py b/tests/test_litellm/proxy/agent_session_endpoints/test_event_append_collision.py index 9b597423eeb..845a7bbae39 100644 --- a/tests/test_litellm/proxy/agent_session_endpoints/test_event_append_collision.py +++ b/tests/test_litellm/proxy/agent_session_endpoints/test_event_append_collision.py @@ -52,9 +52,9 @@ def test_event_append_real_collision_returns_409( json={"name": "t", "model": "gpt-4"}, ).json() sess = client.post( - "/v2/sessions", + f"/v2/agents/{a["id"]}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": a["id"], "repos": []}, + json={"repos": []}, ).json() sid = sess["id"] @@ -109,9 +109,9 @@ def test_event_append_unrelated_error_does_not_become_409( json={"name": "t", "model": "gpt-4"}, ).json() sess = client.post( - "/v2/sessions", + f"/v2/agents/{a["id"]}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": a["id"], "repos": []}, + json={"repos": []}, ).json() sid = sess["id"] daemon_token = sess["daemon_token"] diff --git a/tests/test_litellm/proxy/agent_session_endpoints/test_followup_concurrency.py b/tests/test_litellm/proxy/agent_session_endpoints/test_followup_concurrency.py index a6b45bd4b5a..bd7dc26dd29 100644 --- a/tests/test_litellm/proxy/agent_session_endpoints/test_followup_concurrency.py +++ b/tests/test_litellm/proxy/agent_session_endpoints/test_followup_concurrency.py @@ -23,9 +23,9 @@ def _bootstrap_session(client): json={"name": "concurrent", "model": "gpt-4"}, ).json() sess = client.post( - "/v2/sessions", + f"/v2/agents/{agent["id"]}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": agent["id"], "repos": []}, + json={"repos": []}, ).json() return sess["id"] diff --git a/tests/test_litellm/proxy/agent_session_endpoints/test_followup_smart.py b/tests/test_litellm/proxy/agent_session_endpoints/test_followup_smart.py index dd13133f48f..2af96fd0be5 100644 --- a/tests/test_litellm/proxy/agent_session_endpoints/test_followup_smart.py +++ b/tests/test_litellm/proxy/agent_session_endpoints/test_followup_smart.py @@ -18,9 +18,9 @@ def _bootstrap_ready(client, noop_provider): json={"name": "t", "model": "gpt-4"}, ).json() sess = client.post( - "/v2/sessions", + f"/v2/agents/{agent["id"]}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": agent["id"], "repos": []}, + json={"repos": []}, ).json() daemon_token = sess["daemon_token"] sid = sess["id"] diff --git a/tests/test_litellm/proxy/agent_session_endpoints/test_idempotency.py b/tests/test_litellm/proxy/agent_session_endpoints/test_idempotency.py index 92601004697..2d79114ac09 100644 --- a/tests/test_litellm/proxy/agent_session_endpoints/test_idempotency.py +++ b/tests/test_litellm/proxy/agent_session_endpoints/test_idempotency.py @@ -19,14 +19,14 @@ def test_session_idempotency(client, noop_provider, fake_prisma_client): headers = {"Authorization": "Bearer k", "Idempotency-Key": "uuid-A"} a = client.post( - "/v2/sessions", + f"/v2/agents/{agent_id}/sessions", headers=headers, - json={"agent_id": agent_id, "repos": []}, + json={"repos": []}, ) b = client.post( - "/v2/sessions", + f"/v2/agents/{agent_id}/sessions", headers=headers, - json={"agent_id": agent_id, "repos": []}, + json={"repos": []}, ) assert a.status_code == 200 and b.status_code == 200 assert a.json()["id"] == b.json()["id"] @@ -37,9 +37,9 @@ def test_session_idempotency(client, noop_provider, fake_prisma_client): def test_run_idempotency(client, noop_provider, fake_prisma_client): agent_id = _create_agent(client) sess = client.post( - "/v2/sessions", + f"/v2/agents/{agent_id}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": agent_id, "repos": []}, + json={"repos": []}, ).json() sid = sess["id"] daemon_token = sess["daemon_token"] diff --git a/tests/test_litellm/proxy/agent_session_endpoints/test_ownership.py b/tests/test_litellm/proxy/agent_session_endpoints/test_ownership.py index ab31ae51577..1e249265fc0 100644 --- a/tests/test_litellm/proxy/agent_session_endpoints/test_ownership.py +++ b/tests/test_litellm/proxy/agent_session_endpoints/test_ownership.py @@ -15,9 +15,9 @@ def test_cross_tenant_isolation(client, other_tenant_client, noop_provider): ).json() aid = agent["id"] sess = client.post( - "/v2/sessions", + f"/v2/agents/{aid}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": aid, "repos": []}, + json={"repos": []}, ).json() sid = sess["id"] run = client.post( @@ -52,13 +52,13 @@ def test_cross_tenant_isolation(client, other_tenant_client, noop_provider): assert ( other_tenant_client.get( "/v2/agents", headers={"Authorization": "Bearer other"} - ).json()["data"] + ).json()["items"] == [] ) assert ( other_tenant_client.get( "/v2/sessions", headers={"Authorization": "Bearer other"} - ).json()["data"] + ).json()["items"] == [] ) diff --git a/tests/test_litellm/proxy/agent_session_endpoints/test_run_states.py b/tests/test_litellm/proxy/agent_session_endpoints/test_run_states.py index 75ca9a2ca99..78250c893dd 100644 --- a/tests/test_litellm/proxy/agent_session_endpoints/test_run_states.py +++ b/tests/test_litellm/proxy/agent_session_endpoints/test_run_states.py @@ -52,9 +52,9 @@ def _bootstrap(client, noop_provider): json={"name": "t", "model": "gpt-4"}, ).json() sess = client.post( - "/v2/sessions", + f"/v2/agents/{agent["id"]}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": agent["id"], "repos": []}, + json={"repos": []}, ).json() return agent, sess diff --git a/tests/test_litellm/proxy/agent_session_endpoints/test_session_busy_ready_oscillation.py b/tests/test_litellm/proxy/agent_session_endpoints/test_session_busy_ready_oscillation.py index f274212de74..498557c1f48 100644 --- a/tests/test_litellm/proxy/agent_session_endpoints/test_session_busy_ready_oscillation.py +++ b/tests/test_litellm/proxy/agent_session_endpoints/test_session_busy_ready_oscillation.py @@ -28,9 +28,9 @@ def _bootstrap(client): json={"name": "osc", "model": "gpt-4"}, ).json() sess = client.post( - "/v2/sessions", + f"/v2/agents/{agent["id"]}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": agent["id"], "repos": []}, + json={"repos": []}, ).json() return sess["id"] diff --git a/tests/test_litellm/proxy/agent_session_endpoints/test_session_states.py b/tests/test_litellm/proxy/agent_session_endpoints/test_session_states.py index 87275359182..91ea60c0c98 100644 --- a/tests/test_litellm/proxy/agent_session_endpoints/test_session_states.py +++ b/tests/test_litellm/proxy/agent_session_endpoints/test_session_states.py @@ -71,9 +71,9 @@ def test_session_starts_provisioning(client, noop_provider): agent_id = res.json()["id"] res = client.post( - "/v2/sessions", + f"/v2/agents/{agent_id}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": agent_id, "repos": []}, + json={"repos": []}, ) assert res.status_code == 200 body = res.json() @@ -90,9 +90,9 @@ def test_daemon_register_flips_to_ready(client, noop_provider, fake_prisma_clien agent_id = res.json()["id"] res = client.post( - "/v2/sessions", + f"/v2/agents/{agent_id}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": agent_id, "repos": []}, + json={"repos": []}, ) body = res.json() sid = body["id"] diff --git a/tests/test_litellm/proxy/agent_session_endpoints/test_sse_resume.py b/tests/test_litellm/proxy/agent_session_endpoints/test_sse_resume.py index 8caacb67250..8bc2252f83f 100644 --- a/tests/test_litellm/proxy/agent_session_endpoints/test_sse_resume.py +++ b/tests/test_litellm/proxy/agent_session_endpoints/test_sse_resume.py @@ -26,9 +26,9 @@ def _bootstrap_ready(client, noop_provider): json={"name": "t", "model": "gpt-4"}, ).json() sess = client.post( - "/v2/sessions", + f"/v2/agents/{agent["id"]}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": agent["id"], "repos": []}, + json={"repos": []}, ).json() daemon_token = sess["daemon_token"] sid = sess["id"] diff --git a/tests/test_litellm/proxy/agent_session_endpoints/test_token_scope.py b/tests/test_litellm/proxy/agent_session_endpoints/test_token_scope.py index 66689a82e07..c0914d1dd95 100644 --- a/tests/test_litellm/proxy/agent_session_endpoints/test_token_scope.py +++ b/tests/test_litellm/proxy/agent_session_endpoints/test_token_scope.py @@ -45,14 +45,14 @@ def test_token_for_session_a_rejected_by_session_b(client, noop_provider): json={"name": "x", "model": "gpt-4"}, ).json() sess_a = client.post( - "/v2/sessions", + f"/v2/agents/{a["id"]}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": a["id"], "repos": []}, + json={"repos": []}, ).json() sess_b = client.post( - "/v2/sessions", + f"/v2/agents/{a["id"]}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": a["id"], "repos": []}, + json={"repos": []}, ).json() # Use sess_a's daemon token to register sess_b. @@ -71,9 +71,9 @@ def test_expired_jwt_rejected(client, noop_provider): json={"name": "t", "model": "gpt-4"}, ).json() sess = client.post( - "/v2/sessions", + f"/v2/agents/{a["id"]}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": a["id"], "repos": []}, + json={"repos": []}, ).json() # Mint a token that expired 1 minute ago. @@ -100,9 +100,9 @@ def test_terminated_session_rejects_its_token( json={"name": "t", "model": "gpt-4"}, ).json() sess = client.post( - "/v2/sessions", + f"/v2/agents/{a["id"]}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": a["id"], "repos": []}, + json={"repos": []}, ).json() sid = sess["id"] daemon_token = sess["daemon_token"] diff --git a/tests/test_litellm/proxy/agent_session_endpoints/test_view_only_admin_no_writes.py b/tests/test_litellm/proxy/agent_session_endpoints/test_view_only_admin_no_writes.py index 5c2dc3d326d..79b523710ea 100644 --- a/tests/test_litellm/proxy/agent_session_endpoints/test_view_only_admin_no_writes.py +++ b/tests/test_litellm/proxy/agent_session_endpoints/test_view_only_admin_no_writes.py @@ -25,9 +25,9 @@ def _create_tenant_a_resources(client): json={"name": "tenant-a-agent", "model": "gpt-4"}, ).json() session = client.post( - "/v2/sessions", + f"/v2/agents/{agent["id"]}/sessions", headers={"Authorization": "Bearer k"}, - json={"agent_id": agent["id"], "repos": []}, + json={"repos": []}, ).json() run = client.post( f"/v2/sessions/{session['id']}/runs", @@ -74,9 +74,9 @@ def test_view_only_admin_cannot_create_session(view_only_admin_client, noop_prov # Even minting a session with a non-existent agent must short-circuit # to 403 BEFORE any DB activity — the role check is the first guard. res = view_only_admin_client.post( - "/v2/sessions", + f"/v2/agents/{"agt_doesnotexist"}/sessions", headers={"Authorization": "Bearer view-only"}, - json={"agent_id": "agt_doesnotexist", "repos": []}, + json={"repos": []}, ) assert res.status_code == 403 @@ -159,4 +159,4 @@ def test_view_only_admin_can_still_read_other_tenant_resources( "/v2/agents", headers={"Authorization": "Bearer view-only"} ) assert res.status_code == 200 - assert any(a["id"] == agent_id for a in res.json()["data"]) + assert any(a["id"] == agent_id for a in res.json()["items"])