diff --git a/openapi.json b/openapi.json index 75985c2..39fd603 100644 --- a/openapi.json +++ b/openapi.json @@ -1171,6 +1171,94 @@ } } }, + "/threads/{thread_id}/runs/{run_id}/resume": { + "post": { + "tags": [ + "Runs" + ], + "summary": "Resume Run", + "description": "Resume an existing run on a thread, return the run ID immediately. Don't wait for the final run output.", + "operationId": "resume_run_http_threads__thread_id__runs__run_id__resume_post", + "parameters": [ + { + "description": "The ID of the thread.", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Thread Id", + "description": "The ID of the thread." + }, + "name": "thread_id", + "in": "path" + }, + { + "description": "The ID of the run.", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Run Id", + "description": "The ID of the run." + }, + "name": "run_id", + "in": "path" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RunResumeStateful" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Success", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Run" + } + } + } + }, + "404": { + "description": "Not Found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "409": { + "description": "Conflict", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, "/threads/{thread_id}/runs/{run_id}/cancel": { "post": { "tags": [ @@ -1990,6 +2078,51 @@ "title": "RunCreateStateful", "description": "Payload for creating a run." }, + "RunResumeStateful": { + "properties": { + "input": { + "anyOf": [ + { + "type": "object" + }, + { + "type": "array" + }, + { + "type": "string" + }, + { + "type": "number" + }, + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Input", + "description": "The input to the graph to resume it from an interrupted state." + }, + "messages": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Message" + }, + "title": "Messages", + "description": "The messages to pass an input to the agent." + }, + "after_seconds": { + "type": "integer", + "title": "After Seconds", + "description": "The number of seconds to wait before resuming the run. Use to resume runs in the future." + } + }, + "type": "object", + "required": [], + "title": "RunResumeStateful", + "description": "Payload for resuming a run." + }, "RunWaitResponse": { "type": "object", "properties": { diff --git a/server/ap_server/models.py b/server/ap_server/models.py index 964d257..21dd3f3 100644 --- a/server/ap_server/models.py +++ b/server/ap_server/models.py @@ -408,6 +408,24 @@ class RunCreateStateful(BaseModel): ) +class RunResumeStateful(BaseModel): + input: Optional[Union[Dict[str, Any], List, str, float, bool]] = Field( + None, + description="The input to the graph to resume it from an interrupted state.", + title="Input", + ) + messages: Optional[List[Message]] = Field( + None, + description="The messages to pass an input to the agent.", + title="Messages", + ) + after_seconds: Optional[int] = Field( + None, + description="The number of seconds to wait before resuming the run. Use to resume runs in the future.", + title="After Seconds", + ) + + class RunWaitResponse(BaseModel): run: Optional[Run] = Field(None, description="The run information.", title="Run") values: Optional[Dict[str, Any]] = Field( diff --git a/server/ap_server/routers/runs.py b/server/ap_server/routers/runs.py index 9c8ed37..7794459 100644 --- a/server/ap_server/routers/runs.py +++ b/server/ap_server/routers/runs.py @@ -12,6 +12,7 @@ Optional, Run, RunCreateStateful, + RunResumeStateful, RunWaitResponse, ThreadsThreadIdRunsGetResponse, UUID, @@ -143,6 +144,25 @@ def cancel_run_http_threads__thread_id__runs__run_id__cancel_post( pass +@router.post( + "/threads/{thread_id}/runs/{run_id}/resume", + response_model=Run, + responses={ + "404": {"model": ErrorResponse}, + "409": {"model": ErrorResponse}, + "422": {"model": ErrorResponse}, + }, + tags=["Runs"], +) +def resume_run_http_threads__thread_id__runs__run_id__resume_post( + thread_id: UUID, run_id: UUID = ..., body: RunResumeStateful = ... +) -> Union[Run, ErrorResponse]: + """ + Resume Run + """ + pass + + @router.get( "/threads/{thread_id}/runs/{run_id}/stream", response_model=Any,