Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#376 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
swift
Área
api

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Swift
Estrellas
2.9k
Forks
519
Merge medio
4 d 9 h
PR fusionados (30 d)
13

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de MacPaw/OpenAI

Todos los issues de MacPaw/OpenAI

Issues similares

Más issues de Swift

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.