Skip to content

Commit e9b4278

Browse files
authored
feat(responses)!: improve responses + conversations implementations (#3810)
This PR updates the Conversation item related types and improves a couple critical parts of the implemenation: - it creates a streaming output item for the final assistant message output by the model. until now we only added content parts and included that message in the final response. - rewrites the conversation update code completely to account for items other than messages (tool calls, outputs, etc.) ## Test Plan Used the test script from llamastack/llama-stack-client-python#281 for this ``` TEST_API_BASE_URL=http://localhost:8321/v1 \ pytest tests/integration/test_agent_turn_step_events.py::test_client_side_function_tool -xvs ```
1 parent add8cd8 commit e9b4278

File tree

129 files changed

+86273
-910
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+86273
-910
lines changed

docs/static/deprecated-llama-stack-spec.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8523,6 +8523,12 @@
85238523
{
85248524
"$ref": "#/components/schemas/OpenAIResponseMCPApprovalResponse"
85258525
},
8526+
{
8527+
"$ref": "#/components/schemas/OpenAIResponseOutputMessageMCPCall"
8528+
},
8529+
{
8530+
"$ref": "#/components/schemas/OpenAIResponseOutputMessageMCPListTools"
8531+
},
85268532
{
85278533
"$ref": "#/components/schemas/OpenAIResponseMessage"
85288534
}

docs/static/deprecated-llama-stack-spec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6358,6 +6358,8 @@ components:
63586358
- $ref: '#/components/schemas/OpenAIResponseInputFunctionToolCallOutput'
63596359
- $ref: '#/components/schemas/OpenAIResponseMCPApprovalRequest'
63606360
- $ref: '#/components/schemas/OpenAIResponseMCPApprovalResponse'
6361+
- $ref: '#/components/schemas/OpenAIResponseOutputMessageMCPCall'
6362+
- $ref: '#/components/schemas/OpenAIResponseOutputMessageMCPListTools'
63616363
- $ref: '#/components/schemas/OpenAIResponseMessage'
63626364
"OpenAIResponseInputFunctionToolCallOutput":
63636365
type: object

docs/static/llama-stack-spec.html

Lines changed: 114 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -5479,13 +5479,22 @@
54795479
"$ref": "#/components/schemas/OpenAIResponseMessage"
54805480
},
54815481
{
5482-
"$ref": "#/components/schemas/OpenAIResponseOutputMessageFunctionToolCall"
5482+
"$ref": "#/components/schemas/OpenAIResponseOutputMessageWebSearchToolCall"
54835483
},
54845484
{
54855485
"$ref": "#/components/schemas/OpenAIResponseOutputMessageFileSearchToolCall"
54865486
},
54875487
{
5488-
"$ref": "#/components/schemas/OpenAIResponseOutputMessageWebSearchToolCall"
5488+
"$ref": "#/components/schemas/OpenAIResponseOutputMessageFunctionToolCall"
5489+
},
5490+
{
5491+
"$ref": "#/components/schemas/OpenAIResponseInputFunctionToolCallOutput"
5492+
},
5493+
{
5494+
"$ref": "#/components/schemas/OpenAIResponseMCPApprovalRequest"
5495+
},
5496+
{
5497+
"$ref": "#/components/schemas/OpenAIResponseMCPApprovalResponse"
54895498
},
54905499
{
54915500
"$ref": "#/components/schemas/OpenAIResponseOutputMessageMCPCall"
@@ -5498,9 +5507,12 @@
54985507
"propertyName": "type",
54995508
"mapping": {
55005509
"message": "#/components/schemas/OpenAIResponseMessage",
5501-
"function_call": "#/components/schemas/OpenAIResponseOutputMessageFunctionToolCall",
5502-
"file_search_call": "#/components/schemas/OpenAIResponseOutputMessageFileSearchToolCall",
55035510
"web_search_call": "#/components/schemas/OpenAIResponseOutputMessageWebSearchToolCall",
5511+
"file_search_call": "#/components/schemas/OpenAIResponseOutputMessageFileSearchToolCall",
5512+
"function_call": "#/components/schemas/OpenAIResponseOutputMessageFunctionToolCall",
5513+
"function_call_output": "#/components/schemas/OpenAIResponseInputFunctionToolCallOutput",
5514+
"mcp_approval_request": "#/components/schemas/OpenAIResponseMCPApprovalRequest",
5515+
"mcp_approval_response": "#/components/schemas/OpenAIResponseMCPApprovalResponse",
55045516
"mcp_call": "#/components/schemas/OpenAIResponseOutputMessageMCPCall",
55055517
"mcp_list_tools": "#/components/schemas/OpenAIResponseOutputMessageMCPListTools"
55065518
}
@@ -5658,6 +5670,36 @@
56585670
}
56595671
}
56605672
},
5673+
"OpenAIResponseInputFunctionToolCallOutput": {
5674+
"type": "object",
5675+
"properties": {
5676+
"call_id": {
5677+
"type": "string"
5678+
},
5679+
"output": {
5680+
"type": "string"
5681+
},
5682+
"type": {
5683+
"type": "string",
5684+
"const": "function_call_output",
5685+
"default": "function_call_output"
5686+
},
5687+
"id": {
5688+
"type": "string"
5689+
},
5690+
"status": {
5691+
"type": "string"
5692+
}
5693+
},
5694+
"additionalProperties": false,
5695+
"required": [
5696+
"call_id",
5697+
"output",
5698+
"type"
5699+
],
5700+
"title": "OpenAIResponseInputFunctionToolCallOutput",
5701+
"description": "This represents the output of a function call that gets passed back to the model."
5702+
},
56615703
"OpenAIResponseInputMessageContent": {
56625704
"oneOf": [
56635705
{
@@ -5737,6 +5779,68 @@
57375779
"title": "OpenAIResponseInputMessageContentText",
57385780
"description": "Text content for input messages in OpenAI response format."
57395781
},
5782+
"OpenAIResponseMCPApprovalRequest": {
5783+
"type": "object",
5784+
"properties": {
5785+
"arguments": {
5786+
"type": "string"
5787+
},
5788+
"id": {
5789+
"type": "string"
5790+
},
5791+
"name": {
5792+
"type": "string"
5793+
},
5794+
"server_label": {
5795+
"type": "string"
5796+
},
5797+
"type": {
5798+
"type": "string",
5799+
"const": "mcp_approval_request",
5800+
"default": "mcp_approval_request"
5801+
}
5802+
},
5803+
"additionalProperties": false,
5804+
"required": [
5805+
"arguments",
5806+
"id",
5807+
"name",
5808+
"server_label",
5809+
"type"
5810+
],
5811+
"title": "OpenAIResponseMCPApprovalRequest",
5812+
"description": "A request for human approval of a tool invocation."
5813+
},
5814+
"OpenAIResponseMCPApprovalResponse": {
5815+
"type": "object",
5816+
"properties": {
5817+
"approval_request_id": {
5818+
"type": "string"
5819+
},
5820+
"approve": {
5821+
"type": "boolean"
5822+
},
5823+
"type": {
5824+
"type": "string",
5825+
"const": "mcp_approval_response",
5826+
"default": "mcp_approval_response"
5827+
},
5828+
"id": {
5829+
"type": "string"
5830+
},
5831+
"reason": {
5832+
"type": "string"
5833+
}
5834+
},
5835+
"additionalProperties": false,
5836+
"required": [
5837+
"approval_request_id",
5838+
"approve",
5839+
"type"
5840+
],
5841+
"title": "OpenAIResponseMCPApprovalResponse",
5842+
"description": "A response to an MCP approval request."
5843+
},
57405844
"OpenAIResponseMessage": {
57415845
"type": "object",
57425846
"properties": {
@@ -7213,39 +7317,15 @@
72137317
"$ref": "#/components/schemas/OpenAIResponseMCPApprovalResponse"
72147318
},
72157319
{
7216-
"$ref": "#/components/schemas/OpenAIResponseMessage"
7217-
}
7218-
]
7219-
},
7220-
"OpenAIResponseInputFunctionToolCallOutput": {
7221-
"type": "object",
7222-
"properties": {
7223-
"call_id": {
7224-
"type": "string"
7225-
},
7226-
"output": {
7227-
"type": "string"
7228-
},
7229-
"type": {
7230-
"type": "string",
7231-
"const": "function_call_output",
7232-
"default": "function_call_output"
7320+
"$ref": "#/components/schemas/OpenAIResponseOutputMessageMCPCall"
72337321
},
7234-
"id": {
7235-
"type": "string"
7322+
{
7323+
"$ref": "#/components/schemas/OpenAIResponseOutputMessageMCPListTools"
72367324
},
7237-
"status": {
7238-
"type": "string"
7325+
{
7326+
"$ref": "#/components/schemas/OpenAIResponseMessage"
72397327
}
7240-
},
7241-
"additionalProperties": false,
7242-
"required": [
7243-
"call_id",
7244-
"output",
7245-
"type"
7246-
],
7247-
"title": "OpenAIResponseInputFunctionToolCallOutput",
7248-
"description": "This represents the output of a function call that gets passed back to the model."
7328+
]
72497329
},
72507330
"OpenAIResponseInputToolFileSearch": {
72517331
"type": "object",
@@ -7409,68 +7489,6 @@
74097489
"title": "OpenAIResponseInputToolWebSearch",
74107490
"description": "Web search tool configuration for OpenAI response inputs."
74117491
},
7412-
"OpenAIResponseMCPApprovalRequest": {
7413-
"type": "object",
7414-
"properties": {
7415-
"arguments": {
7416-
"type": "string"
7417-
},
7418-
"id": {
7419-
"type": "string"
7420-
},
7421-
"name": {
7422-
"type": "string"
7423-
},
7424-
"server_label": {
7425-
"type": "string"
7426-
},
7427-
"type": {
7428-
"type": "string",
7429-
"const": "mcp_approval_request",
7430-
"default": "mcp_approval_request"
7431-
}
7432-
},
7433-
"additionalProperties": false,
7434-
"required": [
7435-
"arguments",
7436-
"id",
7437-
"name",
7438-
"server_label",
7439-
"type"
7440-
],
7441-
"title": "OpenAIResponseMCPApprovalRequest",
7442-
"description": "A request for human approval of a tool invocation."
7443-
},
7444-
"OpenAIResponseMCPApprovalResponse": {
7445-
"type": "object",
7446-
"properties": {
7447-
"approval_request_id": {
7448-
"type": "string"
7449-
},
7450-
"approve": {
7451-
"type": "boolean"
7452-
},
7453-
"type": {
7454-
"type": "string",
7455-
"const": "mcp_approval_response",
7456-
"default": "mcp_approval_response"
7457-
},
7458-
"id": {
7459-
"type": "string"
7460-
},
7461-
"reason": {
7462-
"type": "string"
7463-
}
7464-
},
7465-
"additionalProperties": false,
7466-
"required": [
7467-
"approval_request_id",
7468-
"approve",
7469-
"type"
7470-
],
7471-
"title": "OpenAIResponseMCPApprovalResponse",
7472-
"description": "A response to an MCP approval request."
7473-
},
74747492
"OpenAIResponseObjectWithInput": {
74757493
"type": "object",
74767494
"properties": {

0 commit comments

Comments
 (0)