bytedance/deer-flow · error · HTTPException

Run {run_id} is active on another worker; retry after lease

Error message

Run {run_id} is active on another worker; retry after lease expiry.

What it means

Error "Run {run_id} is active on another worker; retry after lease expiry." thrown in bytedance/deer-flow.

Source

Thrown at backend/app/gateway/routers/thread_runs.py:254

async def _raise_lease_valid_elsewhere(
    run_id: str,
    run_mgr,  # RunManager (avoid import for testability)
    record: RunRecord,
) -> None:
    """Re-fetch the lease and raise HTTP 409 + Retry-After.

    ``record.lease_expires_at`` may be stale (fetched at request start while
    the owner renewed between our read and the conditional UPDATE). Re-read
    from the store to get the fresh value so ``Retry-After`` is accurate.
    """
    fresh = await run_mgr.get(run_id)
    if fresh is not None:
        record = fresh
    retry_after = _compute_retry_after(record.lease_expires_at, run_mgr.grace_seconds)
    headers: dict[str, str] = {}
    if retry_after is not None:
        headers["Retry-After"] = str(retry_after)
    raise HTTPException(
        status_code=409,
        detail=f"Run {run_id} is active on another worker; retry after lease expiry.",
        headers=headers,
    )


def _record_to_response(record: RunRecord) -> RunResponse:
    kwargs = dict(record.kwargs or {})
    if "config" in kwargs:
        kwargs["config"] = redact_config_secrets(kwargs["config"])

    return RunResponse(
        run_id=record.run_id,
        thread_id=record.thread_id,
        assistant_id=record.assistant_id,
        status=record.status.value,
        metadata=redact_metadata_secrets(record.metadata),
        kwargs=kwargs,

View on GitHub (pinned to 1dd6ba1acb)

Solutions

  1. Wait for the run's lease to expire (or the run to finish) and retry the operation.
  2. If the other worker crashed, run reconciliation will release the lease automatically; retry shortly.

When it happens

Trigger: Thrown at backend/app/gateway/routers/thread_runs.py:254 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of bytedance/deer-flow@1dd6ba1acb (2026-08-14). Data as JSON: /api/errors/fb2ba89bf4d3e8e4. Report an issue: GitHub.