feat(proxy): drive runs via litellm.managed_agents async task

This commit is contained in:
Ishaan Jaffer 2026-05-06 18:10:18 -07:00
parent 58840a1389
commit 78c69ce273
No known key found for this signature in database

View file

@ -31,6 +31,10 @@ from litellm.proxy.agent_session_endpoints.constants import (
SSE_TERMINAL_QUIESCE_SECONDS,
)
from litellm.proxy.agent_session_endpoints.ids import new_run_id
from litellm.proxy.agent_session_endpoints.managed_agents_runner import (
is_managed_agents_enabled,
schedule_run,
)
from litellm.proxy.agent_session_endpoints.ownership import (
assert_caller_can_mutate,
assert_caller_owns_session,
@ -191,6 +195,14 @@ async def create_run(
# ``ready`` -> ``busy`` flip so SDK consumers polling
# GET /v2/sessions/{id} see the right status.
await refresh_session_status_from_runs(prisma_client, session_id)
# Hand the queued row off to the in-process managed_agents runner
# so the LLM tool loop actually executes. When this is disabled
# (e.g. tests pinned to the legacy NoopVMProvider behavior, or a
# daemon-driven deployment) we leave the row queued for the daemon
# to claim via /runs/next/internal/poll, matching prior behavior.
if is_managed_agents_enabled():
schedule_run(run_id=row.id, session_id=session_id)
return run_row_to_response(row)