This commit is contained in:
Xi Yan 2025-02-20 14:02:17 -08:00
parent ff87677102
commit a44d230676
4 changed files with 354 additions and 339 deletions

View file

@ -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": { "/v1/agents": {
"post": { "post": {
"responses": { "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": { "/v1/post-training/supervised-fine-tune": {
"post": { "post": {
"responses": { "responses": {
@ -5044,62 +5044,10 @@
"title": "CompletionResponseStreamChunk", "title": "CompletionResponseStreamChunk",
"description": "A chunk of a streamed completion response." "description": "A chunk of a streamed completion response."
}, },
"CreateAgentRequest": { "ContinueAgentTurnRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
"agent_config": { "new_messages": {
"$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", "type": "array",
"items": { "items": {
"oneOf": [ "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, "additionalProperties": false,
"required": [ "required": [
"messages" "new_messages"
], ],
"title": "CreateAgentTurnRequest" "title": "ContinueAgentTurnRequest"
}, },
"InferenceStep": { "InferenceStep": {
"type": "object", "type": "object",
@ -5547,7 +5447,7 @@
"$ref": "#/components/schemas/AgentTurnResponseTurnCompletePayload" "$ref": "#/components/schemas/AgentTurnResponseTurnCompletePayload"
}, },
{ {
"$ref": "#/components/schemas/AgentTurnResponseTurnPendingPayload" "$ref": "#/components/schemas/AgentTurnResponseTurnAwaitingInputPayload"
} }
], ],
"discriminator": { "discriminator": {
@ -5558,7 +5458,7 @@
"step_complete": "#/components/schemas/AgentTurnResponseStepCompletePayload", "step_complete": "#/components/schemas/AgentTurnResponseStepCompletePayload",
"turn_start": "#/components/schemas/AgentTurnResponseTurnStartPayload", "turn_start": "#/components/schemas/AgentTurnResponseTurnStartPayload",
"turn_complete": "#/components/schemas/AgentTurnResponseTurnCompletePayload", "turn_complete": "#/components/schemas/AgentTurnResponseTurnCompletePayload",
"turn_pending": "#/components/schemas/AgentTurnResponseTurnPendingPayload" "turn_awaiting_input": "#/components/schemas/AgentTurnResponseTurnAwaitingInputPayload"
} }
} }
}, },
@ -5721,6 +5621,25 @@
"title": "AgentTurnResponseStreamChunk", "title": "AgentTurnResponseStreamChunk",
"description": "streamed agent turn completion response." "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": { "AgentTurnResponseTurnCompletePayload": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -5740,25 +5659,6 @@
], ],
"title": "AgentTurnResponseTurnCompletePayload" "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": { "AgentTurnResponseTurnStartPayload": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -5778,6 +5678,129 @@
], ],
"title": "AgentTurnResponseTurnStartPayload" "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": { "CreateUploadSessionRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -8724,22 +8747,6 @@
], ],
"title": "ScoreBatchResponse" "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": { "AlgorithmConfig": {
"oneOf": [ "oneOf": [
{ {

View file

@ -329,6 +329,45 @@ paths:
schema: schema:
$ref: '#/components/schemas/CompletionRequest' $ref: '#/components/schemas/CompletionRequest'
required: true 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: /v1/agents:
post: post:
responses: responses:
@ -1703,45 +1742,6 @@ paths:
schema: schema:
$ref: '#/components/schemas/ScoreBatchRequest' $ref: '#/components/schemas/ScoreBatchRequest'
required: true 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: /v1/post-training/supervised-fine-tune:
post: post:
responses: responses:
@ -3240,83 +3240,19 @@ components:
title: CompletionResponseStreamChunk title: CompletionResponseStreamChunk
description: >- description: >-
A chunk of a streamed completion response. A chunk of a streamed completion response.
CreateAgentRequest: ContinueAgentTurnRequest:
type: object type: object
properties: properties:
agent_config: new_messages:
$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 type: array
items: items:
oneOf: oneOf:
- $ref: '#/components/schemas/UserMessage' - $ref: '#/components/schemas/UserMessage'
- $ref: '#/components/schemas/ToolResponseMessage' - $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 additionalProperties: false
required: required:
- messages - new_messages
title: CreateAgentTurnRequest title: ContinueAgentTurnRequest
InferenceStep: InferenceStep:
type: object type: object
properties: properties:
@ -3565,7 +3501,7 @@ components:
- $ref: '#/components/schemas/AgentTurnResponseStepCompletePayload' - $ref: '#/components/schemas/AgentTurnResponseStepCompletePayload'
- $ref: '#/components/schemas/AgentTurnResponseTurnStartPayload' - $ref: '#/components/schemas/AgentTurnResponseTurnStartPayload'
- $ref: '#/components/schemas/AgentTurnResponseTurnCompletePayload' - $ref: '#/components/schemas/AgentTurnResponseTurnCompletePayload'
- $ref: '#/components/schemas/AgentTurnResponseTurnPendingPayload' - $ref: '#/components/schemas/AgentTurnResponseTurnAwaitingInputPayload'
discriminator: discriminator:
propertyName: event_type propertyName: event_type
mapping: mapping:
@ -3574,7 +3510,7 @@ components:
step_complete: '#/components/schemas/AgentTurnResponseStepCompletePayload' step_complete: '#/components/schemas/AgentTurnResponseStepCompletePayload'
turn_start: '#/components/schemas/AgentTurnResponseTurnStartPayload' turn_start: '#/components/schemas/AgentTurnResponseTurnStartPayload'
turn_complete: '#/components/schemas/AgentTurnResponseTurnCompletePayload' turn_complete: '#/components/schemas/AgentTurnResponseTurnCompletePayload'
turn_pending: '#/components/schemas/AgentTurnResponseTurnPendingPayload' turn_awaiting_input: '#/components/schemas/AgentTurnResponseTurnAwaitingInputPayload'
AgentTurnResponseStepCompletePayload: AgentTurnResponseStepCompletePayload:
type: object type: object
properties: properties:
@ -3681,6 +3617,21 @@ components:
- event - event
title: AgentTurnResponseStreamChunk title: AgentTurnResponseStreamChunk
description: streamed agent turn completion response. 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: AgentTurnResponseTurnCompletePayload:
type: object type: object
properties: properties:
@ -3695,20 +3646,6 @@ components:
- event_type - event_type
- turn - turn
title: AgentTurnResponseTurnCompletePayload 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: AgentTurnResponseTurnStartPayload:
type: object type: object
properties: properties:
@ -3723,6 +3660,83 @@ components:
- event_type - event_type
- turn_id - turn_id
title: AgentTurnResponseTurnStartPayload 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: CreateUploadSessionRequest:
type: object type: object
properties: properties:
@ -5606,17 +5620,6 @@ components:
required: required:
- results - results
title: ScoreBatchResponse 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: AlgorithmConfig:
oneOf: oneOf:
- $ref: '#/components/schemas/LoraFinetuningConfig' - $ref: '#/components/schemas/LoraFinetuningConfig'

View file

@ -252,7 +252,7 @@ AgentTurnResponseEventPayload = register_schema(
AgentTurnResponseStepCompletePayload, AgentTurnResponseStepCompletePayload,
AgentTurnResponseTurnStartPayload, AgentTurnResponseTurnStartPayload,
AgentTurnResponseTurnCompletePayload, AgentTurnResponseTurnCompletePayload,
AgentTurnResponseTurnPendingPayload, AgentTurnResponseTurnAwaitingInputPayload,
], ],
Field(discriminator="event_type"), Field(discriminator="event_type"),
], ],

View file

@ -169,12 +169,17 @@ class MetaReferenceAgentsImpl(Agents):
async for event in agent.create_and_execute_turn(request): async for event in agent.create_and_execute_turn(request):
yield event yield event
async def submit_tool_response_messages( async def continue_agent_turn(
self, self,
agent_id: str, agent_id: str,
session_id: str, session_id: str,
turn_id: str, turn_id: str,
tool_response_messages: List[ToolResponseMessage], new_messages: List[
Union[
UserMessage,
ToolResponseMessage,
]
],
) -> AsyncGenerator: ) -> AsyncGenerator:
pass pass