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(runs): add run ID filter to runs page (#8726)

Kian Jonesd2c3350a7e9e
diff --git a/letta/server/rest_api/routers/v1/internal_runs.py b/letta/server/rest_api/routers/v1/internal_runs.py
index 420888340..75c2efb67 100644
--- a/letta/server/rest_api/routers/v1/internal_runs.py
+++ b/letta/server/rest_api/routers/v1/internal_runs.py
@@ -30,6 +30,7 @@ def convert_statuses_to_enum(statuses: Optional[List[str]]) -> Optional[List[Run
@router.get("/", response_model=List[Run], operation_id="list_internal_runs")
async def list_runs(
server: "SyncServer" = Depends(get_letta_server),
+ run_id: Optional[str] = Query(None, description="Filter by a specific run ID."),
agent_id: Optional[str] = Query(None, description="The unique identifier of the agent associated with the run."),
agent_ids: Optional[List[str]] = Query(
None,
@@ -110,6 +111,7 @@ async def list_runs(
runs = await runs_manager.list_runs(
actor=actor,
+ run_id=run_id,
agent_ids=agent_ids,
statuses=parsed_statuses,
limit=limit,
diff --git a/letta/services/run_manager.py b/letta/services/run_manager.py
index 1ca63b5f0..be5507349 100644
--- a/letta/services/run_manager.py
+++ b/letta/services/run_manager.py
@@ -138,6 +138,7 @@ class RunManager:
async def list_runs(
self,
actor: PydanticUser,
+ run_id: Optional[str] = None,
agent_id: Optional[str] = None,
agent_ids: Optional[List[str]] = None,
statuses: Optional[List[RunStatus]] = None,
@@ -174,6 +175,9 @@ class RunManager:
if project_id:
query = query.filter(RunModel.project_id == project_id)
+ if run_id:
+ query = query.filter(RunModel.id == run_id)
+
# Handle agent filtering
if agent_id:
agent_ids = [agent_id]