Repository navigation
fix(hooks): 会話外の AskUserQuestion を質問として記録せず、送り主の識別子をログに残す - #3459
Merged
Merged
Conversation
- recordQuestionIfAsked: 直近のターンがエージェント自身の stop で閉じたまま、 送信なしで届いた pre_tool_use(AskUserQuestion)(プロンプトを報告するソースのみ。 #3437 と同じ判定)は質問のレコードを「残さない」方を選んだ。根拠: エピソードの 意味は「画面のピッカーがこれを尋ねている」で、読む側(current-output・respond・ push)に無視の条件を教えるより、書かない方が意味が一つのまま保てる。直前の stop が以前の質問を既に解放しているので、待っている質問は残らない。代わりに ask-user-question-outside-turn を記録する。 - 判定は agent-event-turn の isPreToolUseOutsideTurn(endedByOwnStop と同じ材料)に 一本化し、applyTurnTransition の #3437 の分岐と同じ事実で決まる。 - ログ: hookSenderTags が session_id・agent_id・transcript_path・tool_use_id を shortSessionTag(SHA-256 先頭 8 桁)で、agent_type は名前の形のときだけそのまま返す。 付けるのは ask-user-question-recorded / ask-user-question-outside-turn と、新しい agent-event-pre-tool-use-outside-turn(ターンを開かないと判断した pre_tool_use)だけ。 pre_tool_use 全件には付けない。本文・パス・生の ID は書かない。 - ターンの中の AskUserQuestion の記録・応答・push は不変(#1726 等の既存テストは 無変更で通過。tests/unit/{api,session,hooks,lib/session,lib/hooks} 428 ファイル 6495 件緑)。 新テストの判定を false に変異させると測定シーケンスのケースが赤になることを確認。 対になる場所: - src/lib/hooks/permission-decision-service.ts:501 PermissionRequest(AskUserQuestion) からも recordAskUserQuestion する写し。直さない(下の指摘)。 - src/lib/hooks/sources/opencode/ingest.ts:213, opencode-v2/ingest.ts:249 の記録は question.asked 経由で pre_tool_use の経路を通らず、opencode のターン判定とも別。直さない。 - applyAgentEventToState の promptOpensTurns の計算は intake 内の helper に寄せ、 同じ値を二か所で写さないようにした。 - docs の ja/en: 対象の docs は scope 外。module-reference 追記案は dev-reports に記載。 本文に無い指摘: src/lib/hooks/permission-decision-service.ts:501 PermissionRequest(AskUserQuestion) は会話外かどうかを見ずに質問を記録する。今回の事象で PermissionRequest が届いたかは 未確認のため変更していない。届くなら同じ isPreToolUseOutsideTurn で揃えるか要判断。 環境: ~/.commandmate と ~/.local/state 直下のエントリ名は作業前後で同一(ls -la 比較。 hooks/locks/worktree-index の中身の更新は並行ワーカー由来で、本作業はサーバ・tmux を 起動していない)。service.json は存在しない。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 tasks
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#3437(PR #3441)の調査で、2026-10-07T23:41Z に Claude から、会話記録に存在しない
AskUserQuestionのpre_tool_useが届いたことが分かった。PR #3441 で新しいターンは開かなくなったが、2 つの問題が残っていた(#3446)。1. 質問の記録(
src/lib/hooks/agent-event-intake.tsのrecordQuestionIfAsked): 直近のターンがエージェント自身の Stop で閉じたまま、送信なしで届いたpre_tool_use(AskUserQuestion)(送信を報告するソースのみ。#3437 と同じ判定)は、質問のレコードを残さない。代わりにask-user-question-outside-turnをログに出す。agent-event-turnのisPreToolUseOutsideTurn(endedByOwnStopと同じ材料)に一本化し、fix(session): Stop 直後の送信の無い pre_tool_use で新しいターンが開く #3437 のターンの分岐と同じ事実で決まる2. 送り主のログ:
hookSenderTagsがsession_id・agent_id・transcript_path・tool_use_idを SHA-256 の先頭 8 桁(shortSessionTag)で返す。付けるのは質問の記録の行と、ターンを開かないと判断したpre_tool_useの行(agent-event-pre-tool-use-outside-turn)だけで、pre_tool_use全件には付けない。本文・パス・生の ID は書かない。ターンの中の
AskUserQuestionの記録・応答・push は変わらない(#1726 などの既存テストは無変更で通過)。Refs #3446(develop 向けのため Closes は使わない)
範囲外(この PR では扱わない)
src/lib/hooks/permission-decision-service.ts:501の PermissionRequest(AskUserQuestion) の経路は、会話の外かを見ずに質問を記録する。今回の事象で PermissionRequest が届いたかは未確認 → fix(hooks): PermissionRequest 経由の AskUserQuestion も会話外なら質問として記録しない #3458 で追跡Test plan
commandmatedev verify --task: work-evidence / scope / env-clean / lint / typecheck / unit(テスト全体)すべて PASS(exit 0)tests/unit/hooks/agent-event-intake-question-3446.test.ts。判定を false に変異させると、今回の事象を再現したケースが落ちることを確認(ワーカー)npx tsc --noEmit、hooks・session・api・guards・docs(471 ファイル / 7165 件)が合格。既存のit/describeの削除 0 件🤖 Generated with Claude Code