github / github/copilot-cli

Parallel tool calling non-deterministic response order results in confused bots

Abierto
#4,420 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

area:tools
Lenguaje dominante
Shell
Estrellas
11.2k
Forks
1.9k
Merge medio
14 h 16 min
PR fusionados (30 d)
6

Descripción

Describe the bug

Copilot harness loses request correlation for parallel tool calls

Summary

The Copilot harness does not preserve a reliable association between parallel tool requests and their responses.

The harness can return parallel responses without the original request, a caller-defined alias, or another usable
correlation value. The agent can then associate a response with the wrong request.

Observed behaviour

The agent sent separate service searches for these filters:

{ "type": ["application"] }
{ "type": ["data-product"] }
{ "type": ["kafka-connect"] }

The responses contained different totals. The harness did not return a request alias or the original request with each response. The agent matched the totals to the wrong filters and reported an incorrect breakdown.

The response position was not a safe correlation method.

Image

Expected behaviour

The harness must preserve the association for every parallel invocation.

The parallel call format can accept an optional caller-defined alias:

{
  "request_alias": "kafka-connect-count",
  "tool": "delivery_platform_search_services",
  "arguments": {
    "type": ["kafka-connect"],
    "environment": "prod"
  }
}

Each response must return the alias and the request:

{
  "request_alias": "kafka-connect-count",
  "request": {
    "type": ["kafka-connect"],
    "environment": "prod"
  },
  "result": {
    "pagination": {
      "total_items": 71
    }
  }
}

The harness must not require response order to match request order.

If the caller does not provide an alias, the harness can return its internal call ID. The internal ID alone is not
enough for semantic correlation. The response must also include the original request or another stable request
description.

Suggested fix

Add request metadata to the parallel tool runner.

The runner must:

  1. Accept an optional request_alias for each invocation.
  2. Keep the alias with the invocation while the tool runs.
  3. Return the alias, original arguments, and result together.
  4. Preserve the association when responses complete out of order.
  5. Keep aliases out of the arguments sent to the underlying tool API.

The same response envelope can apply to single tool calls for consistent behaviour.

Workaround

I did a poor-mans implementation of the above, by wrapping our server.registerTool function with something that:

  • Adds an optional request_alias field to registered tool input schemas.
  • Removes request_alias before the tool handler runs.
  • Adds the alias to structuredContent.request_alias in the response.
  • Extends declared output schemas when they exist.
  • Covers JSON, text, generated, and proxied tools.

I also added the following to our instruction file:

  • Assign a unique alias to every parallel invocation.
  • Put the alias in the actual tool arguments.
  • Match responses by alias and exact arguments.
  • Run calls sequentially when a tool does not support aliases.
  • Treat a response without the expected alias as uncorrelated.

That worked well:

Image

But only works for tools we register.

Affected version

1.0.78

Guía de contribución

Abrir la guía de contribución

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.

Línea de trabajo

Empieza rastreando el parallel tool runner y el wrapper server.registerTool descritos en la solución alternativa. Comprueba cómo se incorporan los metadatos de invocación en las respuestas y cómo se pasan los argumentos a la API de la herramienta subyacente. Se considera terminado cuando los alias, las solicitudes originales y los resultados siguen asociados aunque las llamadas finalicen en un orden diferente, sin reenviar los alias como argumentos de la herramienta.

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

Evaluación

Stack tecnológico
shell
Área
cli, tooling
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
55/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.