Repository navigation
feat: report agent hook status to hided and judge status hook first - #1899
Merged
Merged
Conversation
Agent hooks report each session's turn and subagent counts to the core through a hided hook request (`hide workspace status --hook`), proven from the pane like every other hook request, instead of writing Herdr pane metadata. The core keeps the facts per pane and session, lays them on the session it projects, and saves what a restart needs, so the Herdr token restorer is gone. Activity, completion and approval are judged by the hook's turn first, then the session file, then Herdr. Claude Code and Codex register PermissionRequest, Claude Code Notification and Codex Interrupt; the OpenCode plugins and the Pi and omp extension report their turns.
The hook counts are read from the snapshot rather than Herdr pane tokens, and a hook whose report must reach hided runs from inside the agent's own process in its pane, which the pane proof requires.
…hook's session over Herdr's stale one
…hook's session over Herdr's stale one
…ait from the session file
…on file answers it
A key is answered only when its last call has a result, so a command run twice waits on its second run. The helper's session-file check no longer falls back to the tool's last call for a key with an input, so a background subagent's approval, asked after the main Stop under the main session's file, stays open until its call ends. An interruption the session read finds closes the open approvals with the turn.
yansfil
added a commit
that referenced
this pull request
Oct 30, 2026
…undary (#1912) ## Summary Agents in a Hide pane were taught to drive panes with Herdr's own CLI (`herdr agent prompt`, `herdr workspace report-metadata`, `HERDR_BIN_PATH`), which goes around Hide and leaves no letter, reply or retry. This adds the Hide commands that replace them, running through the core's engine boundary, and removes Herdr from everything Hide teaches an agent. - `hide pane read <pane>` and `hide agent read <agent>` print a pane's last 120 lines, unwrapped (`--lines`, at most 2,000). - `hide pane send <pane> <text>` types text and presses Enter only with `--enter` (at most 16 KiB). - `hide pane open --beside [--focus] -- <command>` runs a command in a new pane beside the caller and prints its id; focus stays unless `--focus`. Several words after `--` stay one argument each, quoted for the machine's shell (POSIX, PowerShell on Windows); one word is typed as written. - `hide workspace purpose <text>` sets the checkout's one-line purpose (at most 40 characters). - `hide request send … --force` puts a letter into the recipient's input now, even while it works, and records it like any letter; while someone's text is in that input it is refused with `composer_not_empty` and nothing is typed or recorded. - A refusal is one JSON line with the reason and the next step, and a non-zero exit. 스크린샷 없음: 화면을 바꾸지 않음 (CLI 명령과 에이전트 안내 문구만 바뀜) ``` $ hide request send w1:p1 --intent … --kind report --body "…" --force # agent working, input empty {"ok":true,"result":{"id":"letter-1","forced":true,…}} $ hide request send w1:p1 … --force # "half typed words" in the input {"ok":false,"reason":"composer_not_empty","next_action":"Someone is typing in the recipient's input, so nothing was typed or recorded; send it again without --force, and it is delivered once they submit"} $ hide pane read w1:p1 --lines 2001 {"ok":false,"error":{"code":"lines_out_of_range","message":"Pass --lines from 1 to 2000"}} ``` ## Review - **판단해 주세요**: `--force` checks the input twice, once at send (refuses, records nothing) and again right before typing; if someone started typing in between, the letter is not typed and stays as an ordinary `--now` letter (`delivery.forced_deferred` in the log). Is staying as a letter the right outcome there? - **결정됨 (PRD D-14)**: an agent kind whose hook takes letters at tool calls (five kinds, `tool_letters` in `hide_agent_adapter`) gets a forced letter at its next tool call, as `--now` already does; only kinds without that hook have it typed into their input mid-turn. - **조심해서 볼 파일**: `herdr-core/src/delivery/doorbell.rs` - forced letters skip the working wait, unread turn and draft hold, but still wait on an operator approval or a blocked pane; the composer re-read runs in the pass, off the lock. - **조심해서 볼 파일**: `herdr-core/src/runtime/pane_command.rs` - what is read under `Mutex<Runtime>`: caller proof, target pane or agent, engine handle; every Herdr call runs after the lock in `herdr-core/src/pane_command.rs` `Prepared::run`. - **조심해서 볼 파일**: `hide-agent-hooks/src/install.rs` `Quoting::command_line` - which characters stay bare and the `& ` PowerShell needs before a quoted program; tested for both shells on every system. - **조심해서 볼 파일**: `hided/src/server.rs` - the new `pane` scoped request type is exempt from the 16 KiB frame limit because a send carries up to 16 KiB of text plus its envelope. - **조심해서 볼 파일**: `hide-agent-hooks/src/runtime.rs`, `hided/assets/guide.md` - the guidance text agents read at session start; the guide skill stub moves to version 4 so installed stubs are rewritten. - **비용 검토**: no resident work. Each command is one request; `pane open` polls the new shell at 100 ms for at most 10 s off the lock before typing the command. ## Evidence - **확인한 것**: `scripts/verify-cargo.sh lint && scripts/verify-cargo.sh test` on 4bf7815: 6,555 tests passed, 0 failed (45 binaries); rerun on the final commit is recorded on the mission. - **확인한 것**: one live run per command on an isolated Herdr 0.9.5 with this branch's hided (0c56889) and one agent of a kind without tool-call letters, busy on a sleep job: - `--force` while it worked: the bell line was typed at once, the letter went to delivered with the hook's receipt, and the agent kept working. - `--force` after typing "half typed words" into its input: refused `composer_not_empty`, exit 2; the draft stayed and the refused text never appeared. - `pane read` and `agent read` returned the agent's screen; `agent read` names pane `w1:p1`. - `pane open --beside -- sh -c 'echo X spaced'` ran in a new pane of the same tab with its script as one argument (printed `X spaced`), and focus did not move. - `pane send` without `--enter` typed but did not run the line; with `--enter` it ran. - `workspace purpose` set the workspace's `purpose` token. - Refused with exit 2, reason and next step: 2,001 lines, an unknown pane, an unknown agent, a 41-character purpose, a 16 KiB + 1 send; without a pane credential it was refused `checkout_not_registered`. - The run cleaned up its processes, socket and probe; the config guard restored nothing and reported no change of its own. - **확인한 것**: the input race is pinned by runtime tests: typed into a working agent over an empty input; text in the input at typing time keeps it as a letter; text at send time refuses and records nothing; a deferred letter is held as `draft` for text and `composer_unconfirmed` for an unread screen. - **확인한 것**: runtime tests pin how a command finds its target: an agent by name, registration id or pane, `target_ambiguous` for two of one name, `remote:<device>:pane:<id>` on that device's engine, the purpose's engine workspace or `purpose_no_workspace`, and `caller_context_changed` / `pane_required`. - **확인한 것**: `scripts/check-engine-boundary.py` passes with its allow-list unchanged; tests pin that the session-start note, `hide guide` and `hide mission help` name no Herdr, and that every command they teach is in `contracts/hide-cli.json`. - **확인하지 못한 것**: the second input check (someone starts typing between the send and the typing) was not reproduced live; only the runtime test covers it. - **확인하지 못한 것**: forced letters were run live into one agent kind only, and the commands only on macOS; Linux and Windows run them in this PR's CI lanes. - **확인하지 못한 것**: commands against a connected device's pane (`remote:<device>:pane:<id>`) were not run live. <details><summary>Verification record</summary> - Base: origin/main 83ac3ea; head: see the PR. - Overlap: #1900 and #1899 touch `contracts/hide-cli.json`, `docs/agent-hooks.md`, `hide-agent-hooks/src/runtime.rs` and `hided/src/cli.rs`; merge-order says stay, merge main once after each lands. </details>
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
에이전트 훅이 상태를 Herdr에 쓰고 hide가 그걸 다시 읽던 길을 없애고, 훅이 hided에 직접 보고합니다.
상태는 훅이 보고한 턴, 세션 파일, Herdr 순으로 판단합니다. Herdr의 상태는 세션에 훅 턴이 없을 때만 씁니다.
훅 턴은 같은 세션의 다음 훅 이벤트, 또는 그 턴보다 나중에 읽힌 세션 파일의 턴 끝(Claude Esc 중단 포함)까지 유지되고, 시간 기준은 없습니다. 권한 대기(Claude PermissionRequest와 Notification, Codex PermissionRequest, OpenCode permission)는 waiting 턴으로 보고됩니다.
hided가 없으면 훅은 2초 안에 끝나고, 실패는 화면 경고 없이
last-report-failure.json과 진단 로그에 남습니다.스크린샷 없음: 화면 코드 변경 없음 (
web/src,site/,design/을 건드리지 않음)Review
PermissionRequest가 가리킨 호출(도구 이름과 입력 digest, 키 순서 무관)마다 열린 승인을 두고, 하나라도 열려 있으면 행은 '나를 기다림'입니다. 그 호출이 끝나거나 세션 파일에 결과가 적히면 닫힙니다. 서브에이전트가 연 승인도 같습니다. 메인 Stop은 턴만 끝내고 열린 승인은 그대로 둡니다. Claude 2.1.314는 Agent를 백그라운드로 돌리고, 서브에이전트 이벤트도 메인 session_id로 옵니다(검증 로그로 확인). 프롬프트와 중단은 열린 승인을 모두 닫습니다. 한 세션에 최대 16개입니다.PermissionDenied는 auto mode 전용). 두 곳에서 세션 파일의 결과로 승인을 닫습니다. helper는 다음 훅 이벤트(도구 호출이나 Stop)에서 파일 끝 256 KiB를 읽습니다. 코어는 Herdr 상태 변화마다 label worker가 이미 하는 읽기에서, 최근 64개 호출 중 키별 마지막 호출에 결과가 있는 키를 받아 승인보다 나중 seq일 때 닫습니다. 그래서 의견을 붙여 거절한 뒤 글만 쓰는 턴도 Stop 전에 working이 되고, 같은 명령을 두 번 부르면 둘째 호출의 결과를 기다립니다. 두 곳 모두 입력이 같은 호출만 봅니다. 백그라운드 서브에이전트의 호출은 메인 세션 파일에 없으니, 메인의 같은 도구 호출 결과로 서브에이전트 승인이 닫히지 않습니다. 세션 읽기가 중단(Esc)을 찾으면 턴과 함께 열린 승인도 모두 닫습니다. Mutex 아래 I/O는 없습니다.updatedInput으로 입력을 바꾸면 digest가 달라 그 호출의 끝이 대기를 풀지 못합니다. 세션 파일에 결과가 적힌 뒤의 다음 호출이나 Stop이 풉니다.parentUuid). 그래서 Claude 읽기에서 프롬프트 뒤에 에이전트 기록이 없는 턴을Unanswered로 읽습니다. 훅 턴보다 나중 seq에서 Herdr가 at rest로 읽을 때 그 턴을 쉼(idle)으로 끝냅니다. 시간 문턱은 없습니다. 출력이 있었던 턴에는 적용되지 않습니다. 생각만 하고 아무 기록도 쓰기 전인 턴에서 Herdr가 at rest로 읽으면 잘못 끝날 수 있습니다. 다음 훅 이벤트가 working으로 되돌립니다.PreToolUse와PostToolUse는 매처가 없어 모든 도구에서 돕니다. Codex의 매처는 그대로라 Codex에서 MCP 도구를 승인하면 다음 셸, 질문, 파일 도구나 Stop까지 waiting입니다.claude -p가 보고했다면 그 턴이 보일 수 있습니다.agent_pane_required로 거절됩니다.herdr-core/src/agent_hooks/facts.rs- runtime mutex 밖의 자체 잠금, 저장은LatestFile; 첫 실행에 pane 파일에서 한 번 시드합니다.herdr-core/src/sidebar.rs- 축 판단 순서(hook -> session file -> Herdr)가 바뀐 자리.hided/src/hook_request.rs,hided/src/cli.rs- pane 증명 요구와 failure path(거절도 JSON으로 답함).herdr-core/src/agent_hooks/facts.rs의end_by_session_read와bound- 세션 파일 턴 끝이 훅 턴을 끝내는 조건(그 턴이 처음 놓인 Herdr seq보다 나중의 읽기, Herdr는 idle/done), 그리고 낡은 Herdr 세션보다 훅 세션을 따르는 조건.hide-agent-hooks/src/bin/hide-agent-hooks.rs의report_recorded_turn과run_prompt_hook- prompt 보고를 바깥 프로세스로 옮김. 안쪽 프로세스가 예산에서 잘려도 결과가 남음. 바깥 프로세스가 stdin을 먼저 읽어 그 세션으로 보고하고, 같은 바이트를 안쪽 프로세스 stdin으로 넘김(--payload truncated|unread로 읽기 결과 전달). 그래서 pane에서 마지막으로 보고한claude -p세션에 붙지 않음.hide-session/src/turns.rs의TurnMark::Prompt,TurnMark::Reply,TurnEnded::Unanswered- Claude 읽기만 응답 기록을 표시하므로 다른 에이전트 턴은 Unanswered가 되지 않음.herdr-core/src/agent_hooks/facts.rs가 이를 쉼으로 끝냄.hide-node-link/src/protocol.rs- main의 64(PR 리뷰 상태)와 겹쳐 이 PR의 기기 훅 보고를 NodeLink 65로 올림(docs/ARCHITECTURE.md함께).hide-agent-hooks/src/counters.rs의Said와fold_said- 턴과 열린 승인 집합을 pane 파일 잠금 아래에서 한 번에 바꿈(병렬 훅이 서로 덮지 않게).hide-session/src/calls.rs- 호출 키와 세션 파일 결과 읽기를 helper와 세션 읽기가 함께 씀(helper가 hide-session에 의존하게 됨).herdr-core/src/agent_hooks/facts.rs의close_answered_waits- 보고의waiting과 세션 읽기의answered_calls로 승인을 닫음.hide-host/src/panes.rs- 기기 pane 다리가 거절을 호출자에게 답하기 전에 먼저 기록하게 순서를 바꿈. remote mailbox 레인의node_contract::a_device_pane_s_proof_crosses_the_link_and_its_refusals_are_reported가 31640faa7에서 두 번 연속 실패한 원인입니다. 테스트가 busy 답을 읽고 대기 연결 16개를 닫으면, 그 닫힘 기록이 busy 기록보다 먼저 들어갔습니다.hook_token_link/hook_token_connector를 지웠고,scripts/check-engine-boundary.py의 임시 허용 항목 세 개(hook_tokens.rs, report.rs, hide-agent-hooks.rs)도 지웠습니다.hide-agent-hooks/src/report.rs의deadline- 보고 deadline을 훅 시작 기준으로 하고, entry가 쓰는install::hook_timeout에서 0.5초를 뺀 안쪽으로 묶음(Codex Interrupt 3초).hide-agent-hooks/src/opencode/plugin.js,tui.js,pi_extension/extension.js- 턴 보고를 합쳐 보냄(진행 중 하나, 대기 중 최신 하나).hide-agent-hooks/src/report.rs의 Herdr 호출과herdr-core/src/coordination/hook_tokens.rs(Restorer)를 지웠습니다. 둘 다 엔진 노드의 allowlist에 있습니다.hide프로세스를 하나 띄웁니다.hide하나로 보고합니다. 세션 시작과 서브에이전트 수 변경도 같습니다.labels::tests::an_interruption_is_read_from_the_session_file_with_summaries_off,runtime::tests::labels::a_hook_turn_ends_on_the_session_files_interruption_with_summaries_off).no per-tick reread테스트). 이번 PR은 새 읽기를 더하지 않았고, 이미 읽던 기록에서 턴 끝 표시를 하나 더 꺼냅니다.Mutex<Runtime>아래에서는 파일 I/O가 없습니다. 읽은 결과는 잠금 밖에서 만든 overlay로 넘어오고, 잠금 안에서는 그 읽기의 Herdr seq와 훅 턴의 seq를 비교하는 일만 합니다(end_by_session_read).Evidence
scripts/verify-cargo.sh lint,scripts/verify-cargo.sh test통과.scripts/verify-web.sh web typecheck,web lint통과.{"event":"PermissionRequest","error":"unavailable",...}. 화면 경고 없음.hide프로세스 1개(디버그 약 0.13 s, 부하 없을 때), 도구 이벤트는 0개.hide프로세스 0개. 잘린 Read 결과는format진단을 남기지 않음.[Request interrupted by user], 2.1.314 실제 파일에서 모양 확인, 어댑터 계약 테스트), 같은 pane 재시작(런타임 테스트), 병렬/서브에이전트 호출이 대기를 지우던 것(헬퍼 통합 테스트와 단위 테스트), 사라진 prompt 보고(바깥 프로세스가 보고하고 모든 실패를report.failed로그 줄로 남김), Codex Interrupt 타임아웃 3초.a_waiting_hook_report_reaches_the_row_as_an_approval_until_the_turn_runs_again: Waiting 보고, 재게시 요청, 행approval/stopped(Herdr는 working), 같은 보고 반복 시 요청 없음, Working 보고 후none/working.agent journey워크플로를 fake model로 직접 실행(run 41060503507). linux, macos, windows 각각 7개 에이전트 x 12칸 통과(Grokguidance_memory는 N/A). 각 행은 일하는 중을 읽고 답 뒤에 쉬는 상태를 읽음. 격리된 Herdr 0.9.5와 후보 hided.Interrupt가 실제로 오는지는 실행으로 확인하지 못했습니다.PermissionRequest는 격리 검증에서 0.166.0이 실제로 보냄을 확인했습니다.