From a44d23067698e6c92934155947ea11b1c24d084e Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Thu, 20 Feb 2025 14:02:17 -0800 Subject: [PATCH] rename --- docs/_static/llama-stack-spec.html | 411 +++++++++--------- docs/_static/llama-stack-spec.yaml | 271 ++++++------ llama_stack/apis/agents/agents.py | 2 +- .../inline/agents/meta_reference/agents.py | 9 +- 4 files changed, 354 insertions(+), 339 deletions(-) diff --git a/docs/_static/llama-stack-spec.html b/docs/_static/llama-stack-spec.html index 9a38ed692..72db82f28 100644 --- a/docs/_static/llama-stack-spec.html +++ b/docs/_static/llama-stack-spec.html @@ -554,6 +554,67 @@ } } }, + "/v1/agents/{agent_id}/session/{session_id}/turn/{turn_id}/continue": { + "post": { + "responses": { + "200": { + "description": "A single turn in an interaction with an Agentic System. **OR** streamed agent turn completion response.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Turn" + } + }, + "text/event-stream": { + "schema": { + "$ref": "#/components/schemas/AgentTurnResponseStreamChunk" + } + } + } + } + }, + "tags": [ + "Agents" + ], + "description": "", + "parameters": [ + { + "name": "agent_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "session_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "turn_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ContinueAgentTurnRequest" + } + } + }, + "required": true + } + } + }, "/v1/agents": { "post": { "responses": { @@ -2811,67 +2872,6 @@ } } }, - "/v1/agents/{agent_id}/session/{session_id}/turn/{turn_id}/submit_tool_response_messages": { - "post": { - "responses": { - "200": { - "description": "A single turn in an interaction with an Agentic System. **OR** streamed agent turn completion response.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Turn" - } - }, - "text/event-stream": { - "schema": { - "$ref": "#/components/schemas/AgentTurnResponseStreamChunk" - } - } - } - } - }, - "tags": [ - "Agents" - ], - "description": "", - "parameters": [ - { - "name": "agent_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "session_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "turn_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SubmitToolResponseMessagesRequest" - } - } - }, - "required": true - } - } - }, "/v1/post-training/supervised-fine-tune": { "post": { "responses": { @@ -5044,62 +5044,10 @@ "title": "CompletionResponseStreamChunk", "description": "A chunk of a streamed completion response." }, - "CreateAgentRequest": { + "ContinueAgentTurnRequest": { "type": "object", "properties": { - "agent_config": { - "$ref": "#/components/schemas/AgentConfig" - } - }, - "additionalProperties": false, - "required": [ - "agent_config" - ], - "title": "CreateAgentRequest" - }, - "AgentCreateResponse": { - "type": "object", - "properties": { - "agent_id": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "agent_id" - ], - "title": "AgentCreateResponse" - }, - "CreateAgentSessionRequest": { - "type": "object", - "properties": { - "session_name": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "session_name" - ], - "title": "CreateAgentSessionRequest" - }, - "AgentSessionCreateResponse": { - "type": "object", - "properties": { - "session_id": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "session_id" - ], - "title": "AgentSessionCreateResponse" - }, - "CreateAgentTurnRequest": { - "type": "object", - "properties": { - "messages": { + "new_messages": { "type": "array", "items": { "oneOf": [ @@ -5111,61 +5059,13 @@ } ] } - }, - "stream": { - "type": "boolean" - }, - "documents": { - "type": "array", - "items": { - "type": "object", - "properties": { - "content": { - "oneOf": [ - { - "type": "string" - }, - { - "$ref": "#/components/schemas/InterleavedContentItem" - }, - { - "type": "array", - "items": { - "$ref": "#/components/schemas/InterleavedContentItem" - } - }, - { - "$ref": "#/components/schemas/URL" - } - ] - }, - "mime_type": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "content", - "mime_type" - ], - "title": "Document" - } - }, - "toolgroups": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AgentTool" - } - }, - "tool_config": { - "$ref": "#/components/schemas/ToolConfig" } }, "additionalProperties": false, "required": [ - "messages" + "new_messages" ], - "title": "CreateAgentTurnRequest" + "title": "ContinueAgentTurnRequest" }, "InferenceStep": { "type": "object", @@ -5547,7 +5447,7 @@ "$ref": "#/components/schemas/AgentTurnResponseTurnCompletePayload" }, { - "$ref": "#/components/schemas/AgentTurnResponseTurnPendingPayload" + "$ref": "#/components/schemas/AgentTurnResponseTurnAwaitingInputPayload" } ], "discriminator": { @@ -5558,7 +5458,7 @@ "step_complete": "#/components/schemas/AgentTurnResponseStepCompletePayload", "turn_start": "#/components/schemas/AgentTurnResponseTurnStartPayload", "turn_complete": "#/components/schemas/AgentTurnResponseTurnCompletePayload", - "turn_pending": "#/components/schemas/AgentTurnResponseTurnPendingPayload" + "turn_awaiting_input": "#/components/schemas/AgentTurnResponseTurnAwaitingInputPayload" } } }, @@ -5721,6 +5621,25 @@ "title": "AgentTurnResponseStreamChunk", "description": "streamed agent turn completion response." }, + "AgentTurnResponseTurnAwaitingInputPayload": { + "type": "object", + "properties": { + "event_type": { + "type": "string", + "const": "turn_awaiting_input", + "default": "turn_awaiting_input" + }, + "turn": { + "$ref": "#/components/schemas/Turn" + } + }, + "additionalProperties": false, + "required": [ + "event_type", + "turn" + ], + "title": "AgentTurnResponseTurnAwaitingInputPayload" + }, "AgentTurnResponseTurnCompletePayload": { "type": "object", "properties": { @@ -5740,25 +5659,6 @@ ], "title": "AgentTurnResponseTurnCompletePayload" }, - "AgentTurnResponseTurnPendingPayload": { - "type": "object", - "properties": { - "event_type": { - "type": "string", - "const": "turn_pending", - "default": "turn_pending" - }, - "turn": { - "$ref": "#/components/schemas/Turn" - } - }, - "additionalProperties": false, - "required": [ - "event_type", - "turn" - ], - "title": "AgentTurnResponseTurnPendingPayload" - }, "AgentTurnResponseTurnStartPayload": { "type": "object", "properties": { @@ -5778,6 +5678,129 @@ ], "title": "AgentTurnResponseTurnStartPayload" }, + "CreateAgentRequest": { + "type": "object", + "properties": { + "agent_config": { + "$ref": "#/components/schemas/AgentConfig" + } + }, + "additionalProperties": false, + "required": [ + "agent_config" + ], + "title": "CreateAgentRequest" + }, + "AgentCreateResponse": { + "type": "object", + "properties": { + "agent_id": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "agent_id" + ], + "title": "AgentCreateResponse" + }, + "CreateAgentSessionRequest": { + "type": "object", + "properties": { + "session_name": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "session_name" + ], + "title": "CreateAgentSessionRequest" + }, + "AgentSessionCreateResponse": { + "type": "object", + "properties": { + "session_id": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "session_id" + ], + "title": "AgentSessionCreateResponse" + }, + "CreateAgentTurnRequest": { + "type": "object", + "properties": { + "messages": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/components/schemas/UserMessage" + }, + { + "$ref": "#/components/schemas/ToolResponseMessage" + } + ] + } + }, + "stream": { + "type": "boolean" + }, + "documents": { + "type": "array", + "items": { + "type": "object", + "properties": { + "content": { + "oneOf": [ + { + "type": "string" + }, + { + "$ref": "#/components/schemas/InterleavedContentItem" + }, + { + "type": "array", + "items": { + "$ref": "#/components/schemas/InterleavedContentItem" + } + }, + { + "$ref": "#/components/schemas/URL" + } + ] + }, + "mime_type": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "content", + "mime_type" + ], + "title": "Document" + } + }, + "toolgroups": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AgentTool" + } + }, + "tool_config": { + "$ref": "#/components/schemas/ToolConfig" + } + }, + "additionalProperties": false, + "required": [ + "messages" + ], + "title": "CreateAgentTurnRequest" + }, "CreateUploadSessionRequest": { "type": "object", "properties": { @@ -8724,22 +8747,6 @@ ], "title": "ScoreBatchResponse" }, - "SubmitToolResponseMessagesRequest": { - "type": "object", - "properties": { - "tool_response_messages": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ToolResponseMessage" - } - } - }, - "additionalProperties": false, - "required": [ - "tool_response_messages" - ], - "title": "SubmitToolResponseMessagesRequest" - }, "AlgorithmConfig": { "oneOf": [ { diff --git a/docs/_static/llama-stack-spec.yaml b/docs/_static/llama-stack-spec.yaml index fe94e34ff..efffb3f80 100644 --- a/docs/_static/llama-stack-spec.yaml +++ b/docs/_static/llama-stack-spec.yaml @@ -329,6 +329,45 @@ paths: schema: $ref: '#/components/schemas/CompletionRequest' required: true + /v1/agents/{agent_id}/session/{session_id}/turn/{turn_id}/continue: + post: + responses: + '200': + description: >- + A single turn in an interaction with an Agentic System. **OR** streamed + agent turn completion response. + content: + application/json: + schema: + $ref: '#/components/schemas/Turn' + text/event-stream: + schema: + $ref: '#/components/schemas/AgentTurnResponseStreamChunk' + tags: + - Agents + description: '' + parameters: + - name: agent_id + in: path + required: true + schema: + type: string + - name: session_id + in: path + required: true + schema: + type: string + - name: turn_id + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ContinueAgentTurnRequest' + required: true /v1/agents: post: responses: @@ -1703,45 +1742,6 @@ paths: schema: $ref: '#/components/schemas/ScoreBatchRequest' required: true - /v1/agents/{agent_id}/session/{session_id}/turn/{turn_id}/submit_tool_response_messages: - post: - responses: - '200': - description: >- - A single turn in an interaction with an Agentic System. **OR** streamed - agent turn completion response. - content: - application/json: - schema: - $ref: '#/components/schemas/Turn' - text/event-stream: - schema: - $ref: '#/components/schemas/AgentTurnResponseStreamChunk' - tags: - - Agents - description: '' - parameters: - - name: agent_id - in: path - required: true - schema: - type: string - - name: session_id - in: path - required: true - schema: - type: string - - name: turn_id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/SubmitToolResponseMessagesRequest' - required: true /v1/post-training/supervised-fine-tune: post: responses: @@ -3240,83 +3240,19 @@ components: title: CompletionResponseStreamChunk description: >- A chunk of a streamed completion response. - CreateAgentRequest: + ContinueAgentTurnRequest: type: object properties: - agent_config: - $ref: '#/components/schemas/AgentConfig' - additionalProperties: false - required: - - agent_config - title: CreateAgentRequest - AgentCreateResponse: - type: object - properties: - agent_id: - type: string - additionalProperties: false - required: - - agent_id - title: AgentCreateResponse - CreateAgentSessionRequest: - type: object - properties: - session_name: - type: string - additionalProperties: false - required: - - session_name - title: CreateAgentSessionRequest - AgentSessionCreateResponse: - type: object - properties: - session_id: - type: string - additionalProperties: false - required: - - session_id - title: AgentSessionCreateResponse - CreateAgentTurnRequest: - type: object - properties: - messages: + new_messages: type: array items: oneOf: - $ref: '#/components/schemas/UserMessage' - $ref: '#/components/schemas/ToolResponseMessage' - stream: - type: boolean - documents: - type: array - items: - type: object - properties: - content: - oneOf: - - type: string - - $ref: '#/components/schemas/InterleavedContentItem' - - type: array - items: - $ref: '#/components/schemas/InterleavedContentItem' - - $ref: '#/components/schemas/URL' - mime_type: - type: string - additionalProperties: false - required: - - content - - mime_type - title: Document - toolgroups: - type: array - items: - $ref: '#/components/schemas/AgentTool' - tool_config: - $ref: '#/components/schemas/ToolConfig' additionalProperties: false required: - - messages - title: CreateAgentTurnRequest + - new_messages + title: ContinueAgentTurnRequest InferenceStep: type: object properties: @@ -3565,7 +3501,7 @@ components: - $ref: '#/components/schemas/AgentTurnResponseStepCompletePayload' - $ref: '#/components/schemas/AgentTurnResponseTurnStartPayload' - $ref: '#/components/schemas/AgentTurnResponseTurnCompletePayload' - - $ref: '#/components/schemas/AgentTurnResponseTurnPendingPayload' + - $ref: '#/components/schemas/AgentTurnResponseTurnAwaitingInputPayload' discriminator: propertyName: event_type mapping: @@ -3574,7 +3510,7 @@ components: step_complete: '#/components/schemas/AgentTurnResponseStepCompletePayload' turn_start: '#/components/schemas/AgentTurnResponseTurnStartPayload' turn_complete: '#/components/schemas/AgentTurnResponseTurnCompletePayload' - turn_pending: '#/components/schemas/AgentTurnResponseTurnPendingPayload' + turn_awaiting_input: '#/components/schemas/AgentTurnResponseTurnAwaitingInputPayload' AgentTurnResponseStepCompletePayload: type: object properties: @@ -3681,6 +3617,21 @@ components: - event title: AgentTurnResponseStreamChunk description: streamed agent turn completion response. + "AgentTurnResponseTurnAwaitingInputPayload": + type: object + properties: + event_type: + type: string + const: turn_awaiting_input + default: turn_awaiting_input + turn: + $ref: '#/components/schemas/Turn' + additionalProperties: false + required: + - event_type + - turn + title: >- + AgentTurnResponseTurnAwaitingInputPayload AgentTurnResponseTurnCompletePayload: type: object properties: @@ -3695,20 +3646,6 @@ components: - event_type - turn title: AgentTurnResponseTurnCompletePayload - AgentTurnResponseTurnPendingPayload: - type: object - properties: - event_type: - type: string - const: turn_pending - default: turn_pending - turn: - $ref: '#/components/schemas/Turn' - additionalProperties: false - required: - - event_type - - turn - title: AgentTurnResponseTurnPendingPayload AgentTurnResponseTurnStartPayload: type: object properties: @@ -3723,6 +3660,83 @@ components: - event_type - turn_id title: AgentTurnResponseTurnStartPayload + CreateAgentRequest: + type: object + properties: + agent_config: + $ref: '#/components/schemas/AgentConfig' + additionalProperties: false + required: + - agent_config + title: CreateAgentRequest + AgentCreateResponse: + type: object + properties: + agent_id: + type: string + additionalProperties: false + required: + - agent_id + title: AgentCreateResponse + CreateAgentSessionRequest: + type: object + properties: + session_name: + type: string + additionalProperties: false + required: + - session_name + title: CreateAgentSessionRequest + AgentSessionCreateResponse: + type: object + properties: + session_id: + type: string + additionalProperties: false + required: + - session_id + title: AgentSessionCreateResponse + CreateAgentTurnRequest: + type: object + properties: + messages: + type: array + items: + oneOf: + - $ref: '#/components/schemas/UserMessage' + - $ref: '#/components/schemas/ToolResponseMessage' + stream: + type: boolean + documents: + type: array + items: + type: object + properties: + content: + oneOf: + - type: string + - $ref: '#/components/schemas/InterleavedContentItem' + - type: array + items: + $ref: '#/components/schemas/InterleavedContentItem' + - $ref: '#/components/schemas/URL' + mime_type: + type: string + additionalProperties: false + required: + - content + - mime_type + title: Document + toolgroups: + type: array + items: + $ref: '#/components/schemas/AgentTool' + tool_config: + $ref: '#/components/schemas/ToolConfig' + additionalProperties: false + required: + - messages + title: CreateAgentTurnRequest CreateUploadSessionRequest: type: object properties: @@ -5606,17 +5620,6 @@ components: required: - results title: ScoreBatchResponse - SubmitToolResponseMessagesRequest: - type: object - properties: - tool_response_messages: - type: array - items: - $ref: '#/components/schemas/ToolResponseMessage' - additionalProperties: false - required: - - tool_response_messages - title: SubmitToolResponseMessagesRequest AlgorithmConfig: oneOf: - $ref: '#/components/schemas/LoraFinetuningConfig' diff --git a/llama_stack/apis/agents/agents.py b/llama_stack/apis/agents/agents.py index c3301d5ed..05ddf587a 100644 --- a/llama_stack/apis/agents/agents.py +++ b/llama_stack/apis/agents/agents.py @@ -252,7 +252,7 @@ AgentTurnResponseEventPayload = register_schema( AgentTurnResponseStepCompletePayload, AgentTurnResponseTurnStartPayload, AgentTurnResponseTurnCompletePayload, - AgentTurnResponseTurnPendingPayload, + AgentTurnResponseTurnAwaitingInputPayload, ], Field(discriminator="event_type"), ], diff --git a/llama_stack/providers/inline/agents/meta_reference/agents.py b/llama_stack/providers/inline/agents/meta_reference/agents.py index c208388be..cb8192968 100644 --- a/llama_stack/providers/inline/agents/meta_reference/agents.py +++ b/llama_stack/providers/inline/agents/meta_reference/agents.py @@ -169,12 +169,17 @@ class MetaReferenceAgentsImpl(Agents): async for event in agent.create_and_execute_turn(request): yield event - async def submit_tool_response_messages( + async def continue_agent_turn( self, agent_id: str, session_id: str, turn_id: str, - tool_response_messages: List[ToolResponseMessage], + new_messages: List[ + Union[ + UserMessage, + ToolResponseMessage, + ] + ], ) -> AsyncGenerator: pass