mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-04 02:31:27 +00:00
fix(internal_endpoints): drive session busy<->ready oscillation from daemon callbacks
Two call sites added:
* After _claim_next_queued_run flips a queued run to running, call
refresh_session_status_from_runs so a session that was 'ready'
transitions to 'busy'. Idempotent for already-busy sessions.
* After daemon_append_event finalizes a terminal event (run_finished /
run_cancelled / run_error), call refresh_session_status_from_runs so
a session with no remaining active runs transitions back to 'ready'.
Without these hooks, session.status stayed permanently 'busy' after the
first run started — clients polling GET /v2/sessions/{id} always saw
'busy' regardless of run state.
Greptile P1 (review #PRR_kwDOKALCgc78u9En).
This commit is contained in:
parent
f68869071b
commit
f3101be1a1
1 changed files with 12 additions and 0 deletions
|
|
@ -33,6 +33,9 @@ from litellm.proxy.agent_session_endpoints.constants import (
|
|||
SESSION_STATUS_PROVISIONING,
|
||||
SESSION_STATUS_READY,
|
||||
)
|
||||
from litellm.proxy.agent_session_endpoints.session_status import (
|
||||
refresh_session_status_from_runs,
|
||||
)
|
||||
from litellm.proxy.agent_session_endpoints.schemas import (
|
||||
DaemonHeartbeatRequest,
|
||||
DaemonRegisterRequest,
|
||||
|
|
@ -185,6 +188,11 @@ async def daemon_next_run(
|
|||
while True:
|
||||
claimed = await _claim_next_queued_run(prisma_client, session_id)
|
||||
if claimed is not None:
|
||||
# Run just transitioned queued -> running; if the session is
|
||||
# still ``ready``, flip it to ``busy``. Idempotent — if the
|
||||
# session is already ``busy`` (e.g. concurrent runs), this
|
||||
# is a no-op via ``derive_session_status_from_runs``.
|
||||
await refresh_session_status_from_runs(prisma_client, session_id)
|
||||
return NextRunResponse(
|
||||
run_id=claimed.id,
|
||||
prompt=claimed.prompt or {},
|
||||
|
|
@ -282,6 +290,10 @@ async def daemon_append_event(
|
|||
),
|
||||
},
|
||||
)
|
||||
# Drive the session ``busy`` -> ``ready`` flip. Without this,
|
||||
# the parent session stays permanently ``busy`` after the first
|
||||
# run terminates — Greptile P1.
|
||||
await refresh_session_status_from_runs(prisma_client, session_id)
|
||||
|
||||
return {
|
||||
"run_id": run_id,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue