Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

DecodingError when handling MCP tool calls - type 'mcp_call' not recognized

Đang mở
#376 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
swift
Lĩnh vực
api

Hướng nghiên cứu

Start by tracing the ResponseOutputItemDoneEvent decoder and the OutputItem schema handling mentioned in the report; reproduce with a streaming CreateModelResponseQuery using Tool.mcpTool(). The issue is resolved when an event whose item type is mcp_call decodes without a DecodingError and the stream continues.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Bug Description

When using MCP tools with the CreateModelResponseQuery API, the library throws a DecodingError when processing MCP tool call events.

Error Details

valueNotFound(OpenAI.Components.Schemas.OutputItem, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "item", intValue: nil)], debugDescription: "The anyOf structure did not decode into any child schema."))

Cannot initialize _TypePayload from invalid String value mcp_call

Root Cause

The server sends OutputItem with type "mcp_call" (with underscore), but the OutputItem decoder in ResponseOutputItemDoneEvent fails to decode this properly.

Steps to Reproduce

  1. Configure an MCP tool using Tool.mcpTool()
  2. Send a query using CreateModelResponseQuery with the MCP tool
  3. When the model invokes the MCP tool, the stream processing fails with a DecodingError

Expected Behavior

The library should properly decode MCP tool call events without throwing errors.

Code Example

let mcpTool = Tool.mcpTool(
    Components.Schemas.MCPTool(
        _type: .mcp,
        serverLabel: "playwright-mcp",
        serverUrl: "https://example.com/mcp",
        headers: Components.Schemas.MCPTool.HeadersPayload(additionalProperties: ["Authorization": "Bearer token"]),
        allowedTools: .case1(["browser_navigate"]),
        requireApproval: .case2(.never)
    )
)

let query = CreateModelResponseQuery(
    input: .inputItemList(inputItems),
    model: "gpt-5-2025-08-07",
    stream: true,
    tools: [mcpTool]
)

let stream: AsyncThrowingStream<ResponseStreamEvent, Error> = client.responses.createResponseStreaming(query: query)

// This fails when MCP tool is called
for try await event in stream {
    // Processing fails with DecodingError
}

Environment

  • Library Version: Latest main branch
  • Swift Version: 5.x
  • Platform: iOS
  • Xcode Version: Latest

Workaround

Currently catching and ignoring the DecodingError allows the stream to continue, but this is not ideal as it may hide other legitimate errors.

Ngôn ngữ chính
Swift
Star
2.9k
Fork
519
Merge trung bình
4 ngày 9 giờ
Pull request đã merge (30 ngày)
13

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của MacPaw/OpenAI

Tất cả issue của MacPaw/OpenAI

Issue tương tự

Thêm issue về Swift

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.