Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

feat: add active filter to runs endpoint and deprecate list active runs (#2972)

cthomas74c2f2891b2e
diff --git a/letta/server/rest_api/routers/v1/runs.py b/letta/server/rest_api/routers/v1/runs.py
index 8bfaaddf9..a622dba65 100644
--- a/letta/server/rest_api/routers/v1/runs.py
+++ b/letta/server/rest_api/routers/v1/runs.py
@@ -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
[email protected]("/active", response_model=List[Run], operation_id="list_active_runs")
[email protected]("/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."),