Skip to content

[DOCS] Document command hooks (hooks.yaml) #287

Closed

Description

@edenreich

Summary

infer can now run user-configured shell commands at agent-loop hook points (source: inference-gateway/cli#270), the executable sibling of the system reminders added in inference-gateway/cli#669. Commands live in a dedicated .infer/hooks.yaml, are feature-flagged off by default, and are gated through the existing per-mode bash allow-list (no new bypass of the secure-by-default model). The docs site needs a page covering the feature.

User-facing behavior to document:

  • New config file .infer/hooks.yaml (project) / ~/.infer/hooks.yaml (userspace), generated by infer init:

    enabled: false
    hooks:
      - name: gofmt
        hook: post_session
        command: "gofmt -w ."
        timeout: 30   # seconds; 0 -> default 30
  • hook is one of the pre-defined hook points: pre_session, pre_stream, post_stream, pre_tool, post_tool, pre_queue_drain, post_queue_drain, post_session. post_session ("agent finished generating") is the primary one, for deterministic post-processing (format, lint, test, notify).

  • Authorization: a command runs only if it passes the per-mode bash allow-list (tools.bash.mode.*.allow); an off-list command is skipped and reported, never run. To allow a command unattended (CI), add it to the allow-list or use INFER_TOOLS_BASH_ALLOW_APPEND, e.g. INFER_TOOLS_BASH_ALLOW_APPEND="gofmt.*" so gofmt -w . runs at post_session.

  • Master switch env override: INFER_HOOKS_ENABLED=true.

  • v1 is fire-and-observe: each run emits a hook_command stream event (name, exit code, duration, truncated output); output is not fed back into the conversation.

Affected pages / proposed locations:

  • A new "Hooks" page under the CLI configuration docs, alongside the reminders / reminders.yaml page.
  • The configuration-files reference/table: add the hooks.yaml row (mirroring reminders.yaml).

Acceptance Criteria

  • A docs page documents hooks.yaml (schema: enabled, hooks[].name/hook/command/timeout) with the infer init default example.
  • The allow-list authorization model is documented (off-list -> skipped; allow-list or INFER_TOOLS_BASH_ALLOW_APPEND to enable; secure-by-default headless).
  • The hook-point catalog and the post_session CI post-processing example are documented.
  • The configuration-files reference lists hooks.yaml.

Source: inference-gateway/cli#270 (implementation); builds on inference-gateway/cli#669.

Activity

  1. added
    documentation
    on Jun 28, 2026
  2. added theissue type on Jun 28, 2026
  3. edenreich commented on Jun 28, 2026

    @edenreich
    ContributorAuthor

    @infer /model ollama_cloud/glm-5.2 Can you document it?

  4. inference-gateway-maintainer commented on Jun 28, 2026

    @inference-gateway-maintainer
    Contributor

    View Job

    Todos

    • Explore repo structure and find reminders.yaml docs page to mirror
    • Create new Hooks page documenting hooks.yaml schema and behavior
    • Update configuration-files reference to list hooks.yaml
    • Verify build/lint passes and review changes
    • Commit changes, push branch, open PR referencing [DOCS] Document command hooks (hooks.yaml) #287

    Pull Request

    #293

    ✅ Infer Result: Success

    PR #293 is open and linked to issue #287. No further work needed.

    Model: ollama_cloud/glm-5.2 · Exit Code: 0 · Duration: 7m 38s

    Tokens: 2,992,749 in · 15,945 out · 3,008,694 total (55 requests)

    Tool calls: 66 total · 91% success rate

    ⚠️ 6 failed tool call(s)
    • TodoWrite: todos parameter is required and must be an array
    • TodoWrite: todos parameter is required and must be an array
    • Bash: exit status 127: bash: line 1: prettier: command not found
    • Bash: exit status 1: cli-hooks.md:209:75 error MD047/single-trailing-newline Files should end with a single newline character
    • Bash: exit status 1: Checking formatting...
      [�[33mwarn�[39m] cli-hooks.md
      [�[33mwarn�[39m] cli.md
      [�[33mwarn�[39m] Code style issues found in 2 files. Run Prettier with --write to fix.
    • Bash: exit status 1: cli-hooks.md:209:75 error MD047/single-trailing-newline Files should end with a single newline character

    Triggered by edenreich · Infer Action

  5. inference-gateway-releaser commented on Jun 29, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.6.114 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

  6. moved this from Todo to Done in 2026on Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationreleased

    Type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions