feat: add active filter to runs endpoint and deprecate list active runs (#2972)
This commit is contained in:
@@ -36,6 +36,7 @@ def list_runs(
|
||||
after: Optional[str] = Query(None, description="Cursor for pagination"),
|
||||
before: Optional[str] = Query(None, description="Cursor for pagination"),
|
||||
limit: Optional[int] = Query(50, description="Maximum number of runs to return"),
|
||||
active: bool = Query(False, description="Filter for active runs."),
|
||||
ascending: bool = Query(
|
||||
False,
|
||||
description="Whether to sort agents oldest to newest (True) or newest to oldest (False, default)",
|
||||
@@ -46,11 +47,15 @@ def list_runs(
|
||||
List all runs.
|
||||
"""
|
||||
actor = server.user_manager.get_user_or_default(user_id=headers.actor_id)
|
||||
statuses = None
|
||||
if active:
|
||||
statuses = [JobStatus.created, JobStatus.running]
|
||||
|
||||
runs = [
|
||||
Run.from_job(job)
|
||||
for job in server.job_manager.list_jobs(
|
||||
actor=actor,
|
||||
statuses=statuses,
|
||||
job_type=JobType.RUN,
|
||||
limit=limit,
|
||||
before=before,
|
||||
@@ -66,7 +71,7 @@ def list_runs(
|
||||
return runs
|
||||
|
||||
|
||||
@router.get("/active", response_model=List[Run], operation_id="list_active_runs")
|
||||
@router.get("/active", response_model=List[Run], operation_id="list_active_runs", deprecated=True)
|
||||
def list_active_runs(
|
||||
server: "SyncServer" = Depends(get_letta_server),
|
||||
agent_ids: Optional[List[str]] = Query(None, description="The unique identifier of the agent associated with the run."),
|
||||
|
||||
Reference in New Issue
Block a user