acp: usage_update is not sent when a turn fails

オープン 初心者向け
#67,009 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
半日
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust, typescript
領域
api

調査の方向性

まず packages/cli/src/acp/turn.ts、特に settle を読み、次に packages/cli-rs/crates/acp/src/turn.rs の同じ制御フローを比較します。Issue で説明されている opencode acp セッションの流れを再現します。完了の条件は、失敗したプロンプトターンがエラーを返す前に、累積された usage_update 通知を出力することです。成功したターン、キャンセルされたターン、およびコンテンツでフィルターされたターンは変更しないままにします。

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
TypeScript
スター
230k
フォーク
31.3k
平均マージ
5時間 32分
マージ済み PR(30日)
453

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

anomalyco/opencode のほかの issue

anomalyco/opencode の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。