Skip to content

[Feature]: Run Claude Code's managed hook as the native orca-agent-hook on macOS and Linux #41889

Open

Description

@yasyf

Problem or use case

On macOS and Linux, every Claude Code hook event runs a process chain: Claude's sh -c, sh ~/.orca/agent-hooks/claude-hook.sh, cat, the agent identity (ps twice on macOS), and curl. #38180 took that from 17 processes to 7. On Windows, #20913 replaced the same chain with one std-only Rust executable, orca-agent-hook.exe, registered in exec form, because each extra process start cost about 980 ms per event there.

The per-process cost on macOS is not small either. Under an endpoint detection and response (EDR) agent such as SentinelOne, which inspects every exec through EndpointSecurity, each exec costs about 0.5 s of admission wait, and one 5.5 s eslogger exec capture showed Orca's Claude hook and status line making about 290 of the 1,040 execs on the machine (28%). Claude Code waits for PreToolUse before every tool call.

Proposed solution

Build native/windows-agent-hook for macOS and Linux too, ship it in the app bundle as Contents/Resources/bin/orca-agent-hook (signed with the app like the other bundled binaries), copy it into ~/.orca/agent-hooks the way the Windows exe is copied, and register it in exec form (command plus args: ["claude", <script path>]) for Claude versions that claudeAcceptsExecFormHooks accepts. Older Claude versions, SSH hosts and WSL keep claude-hook.sh.

The macOS and Linux build keeps the script's contract, byte for byte where the server compares:

  • the endpoint-file refresh for terminals that outlive an Orca restart, and the spool when Orca is down;
  • the agent identity: getppid() is Claude's PID with no shell in between, the start time comes from proc_pidinfo on macOS (formatted as ps -o lstart= prints it under TZ=UTC0 LC_ALL=C) and /proc/<pid>/stat plus boot_id on Linux;
  • the PreToolUse and PermissionRequest decisions (X-Orca-Hook-Decision, 8 s and 126 s, {} on anything else);
  • the scrub-safe environment restore, the CLAUDE_JOB_DIR, Grok, Cursor and Devin guards, the metadata header and the tmux pane header.

Result: one process per Claude hook event on macOS and Linux, down from 7 (macOS) and 6 (Linux) after #38180, with the same headers and body at the server.

I can open a PR for this. Since it adds a native build to the macOS and Linux packaging jobs, I would like to know whether you want it before sending it.

Alternatives or additional context

Activity

  1. AmethystLiang commented on Nov 13, 2026

    @AmethystLiang
    Contributor

    Triage: assigning to @brennanb2025 because this issue is primarily a Native Chat / agent integration concern.

  2. AmethystLiang commented on Nov 13, 2026

    @AmethystLiang
    Contributor

    Triage: keeping @brennanb2025 assigned because the issue matches their ownership area.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions