acp: usage_update is not sent when a turn fails

Đang mở Phù hợp với người mới
#67,009 2 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 1 ngày

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

Đánh giá

Độ khó
2/5
Thời gian dự kiến
Nửa ngày
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust, typescript
Lĩnh vực
api

Hướng nghiên cứu

Bắt đầu bằng cách đọc packages/cli/src/acp/turn.ts, đặc biệt là settle, sau đó so sánh cùng luồng điều khiển trong packages/cli-rs/crates/acp/src/turn.rs. Tái hiện luồng phiên opencode acp được mô tả trong issue. Hoàn thành nghĩa là lượt prompt thất bại sẽ phát ra thông báo usage_update đã tích lũy trước khi trả về lỗi, trong khi các lượt thành công, bị hủy và bị lọc nội dung vẫn không thay đổi.

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

Mô tả

Description

Over ACP, when a prompt turn ends in an error (provider error, rate limit, auth), opencode replies with the error but never sends usage_update. Usage from the turn's earlier steps, and from the failed step when the provider reports tokens, never reaches the client, so ACP clients undercount context and cost. Successful, cancelled and content-filtered turns do send it.

The adapter already counts these tokens (session.step.failed is folded into the turn usage). In settle in packages/cli/src/acp/turn.ts, the failure returns before sendUsageUpdate runs. packages/cli-rs/crates/acp/src/turn.rs has the same order. Sending the usage update before returning the error would fix it; the error response itself can't carry PromptResponse.usage.

Related but different: #66734 asks for usage at session start and after each model call.

Plugins

None

OpenCode version

2.4.2, still present on dev

Steps to reproduce
  1. Start opencode acp, then initialize and session/new.
  2. Send a prompt that makes at least one tool call, then fails on a later model call (e.g. the provider returns a rate limit or 500).
  3. The session/prompt call returns an error and no usage_update notification is sent for that turn.
Ngôn ngữ chính
TypeScript
Star
230k
Fork
31.3k
Merge trung bình
5 giờ 32 phút
Pull request đã merge (30 ngày)
453

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 anomalyco/opencode

Tất cả issue của anomalyco/opencode

Issue tương tự

Thêm issue về TypeScript

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.