github / github/copilot-cli

[ACP] Emit `usage_update` in `--acp` mode (context window + AI credits) for parity with the interactive statusline

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

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

area:non-interactive
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 feature or problem you'd like to solve

copilot --acp never emits the ACP usage_update session update, so ACP clients (Zed, etc.) can't show a context-window or AI-credit usage indicator for Copilot — even though the CLI already computes this data for /context, /usage, and the statusline.

Proposed solution
Summary

When Copilot CLI runs in ACP mode (copilot --acp), it never sends the ACP
session/update notification with sessionUpdate: "usage_update". As a result,
ACP clients (Zed and other editors/tools integrating over ACP) cannot show a
context‑window usage indicator or AI‑credit usage for Copilot — even though the
CLI already computes this data and surfaces it in interactive mode.

The gap: interactive mode has it, ACP mode doesn't

In interactive mode the data is already there:

  • The experimental statusLine.command receives JSON with
    context_window.current_context_tokens, context_window.displayed_context_limit,
    context_window.current_context_used_percentage, etc.
  • /context shows the context‑window breakdown.
  • /usage shows AI credits used in the current session.

But in --acp mode none of it is forwarded — the client only ever receives
agent_message_chunk, tool_call, available_commands_update, etc., and never a
usage_update (even though the type is part of the ACP schema the CLI already speaks).

Why it matters
  • ACP standardized session usage reporting (Session Context Size & Cost RFD).
    usage_update carries { used, size } (+ optional cost) and powers Zed's
    context‑window indicator.
  • Other ACP agents (e.g. Claude Code via claude-agent-acp) emit usage_update, so
    their users get a live context indicator in Zed. Copilot users don't — Zed falls
    back to inaccurate estimation (see zed-industries/zed#44909, where Copilot models
    show a hardcoded 128k limit that doesn't match the real limit).
  • For long agentic sessions, knowing how close you are to compaction — and how many
    credits you've spent — is valuable.
Request

In --acp mode, emit session/update with sessionUpdate: "usage_update":

  • After session/new, session/load, session/resume, and after each prompt turn.
  • Populate the standard fields: used (current context tokens), size (context
    window size), and cost (session cost) when available.
  • For AI credits (used / remaining) — which have no standard ACP field — attach them
    via the update's _meta (already part of the usage_update schema), e.g.
    _meta: { ai_credits_used, ai_credits_remaining }.

This brings ACP mode to parity with the interactive statusline / /context /
/usage, with no new data to compute — just forwarding what already exists over the
protocol the CLI already implements.

References
  • ACP usage_update (Session Context Size & Cost RFD)
  • Zed context indicator; zed-industries/zed#44909 (Copilot token limits estimated / incorrect)
  • Related CLI requests: #2052 (persistent token/context indicator), #1953 (always‑visible context status)
Example prompts or workflows

No response

Additional context

No response

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 tại điểm vào --acp và lần theo việc xử lý session/new, session/load, session/resume và prompt-turn. So sánh dữ liệu hiện có từ /context, /usage và statusline với schema ACP session/update, sau đó xác minh rằng usage_update báo cáo used, size, cost và siêu dữ liệu AI-credit được yêu cầu sau mỗi sự kiện vòng đời.

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
Loại issue
Tính năng
Độ 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
48/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.