github / github/copilot-cli

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

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

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

area:tools
Ngôn ngữ chính
Shell
Star
11.2k
Fork
1.9k
Merge trung bình
14 giờ 16 phút
Pull request đã merge (30 ngày)
6

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

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.

Hướng nghiên cứu

Bắt đầu bằng cách lần theo parallel tool runner và wrapper server.registerTool được mô tả trong workaround. Kiểm tra cách siêu dữ liệu gọi được truyền vào các phản hồi và cách các đối số được truyền tới API công cụ bên dưới. Được xem là hoàn tất khi các bí danh, yêu cầu ban đầu và kết quả vẫn được liên kết với nhau dù các lệnh gọi hoàn tất không theo thứ tự, mà không chuyển tiếp các bí danh dưới dạng đối số của công cụ.

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

Đánh giá

Công nghệ
shell
Lĩnh vực
cli, tooling
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
55/100

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.