feat(gateway): command hooks for deterministic chat commands - #199
Draft
bkuri wants to merge 1 commit into
Draft
Conversation
[command_hooks] maps chat slash commands to shell commands whose stdout is relayed verbatim before any backend dispatch — no agent turn, no tokens. Message arguments are appended to the command line as trailing positional arguments. Failing, empty, or timed-out hooks reply with a short deterministic error and never fall back to the backend; unknown slash commands still reach the backend unchanged. Basis for deterministic /status-style commands on chat backends; the timeout-hook runner from owainlewis#197 can absorb this execution path later.
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.
Problem
Every chat message today — including slash commands — costs a full backend turn. Gateway built-ins (
/clear,/help,/stop) short-circuit, but anything user-defined has to route through the LLM even when the desired behavior is fully deterministic (e.g./statusrunning a status script and relaying its output).Change
Adds a
[command_hooks]config table mapping chat slash commands to shell commands, handled in the existing gateway command path before backend dispatch:/status agents→status-report agents)./bin/sh(POSIX), stdout+stderr captured,kill_on_dropon timeout.Verification
cargo fmt --all --check,cargo clippy --locked --all-targets -- -D warnings,cargo build --locked,cargo test --lockedall pass (448 tests).mkdocs build --strict).Risk
Low: default config (
command_hooksempty) is behavior-identical to today. Thecommand()signature gainsasync— call site is already async context. Docs updated on the canonical page (docs/reference/cli.md).Note: the hardened hook runner in #197 (process groups, stdout cap) is a better execution engine for this path; this PR deliberately ships the simpler runner to stay focused, and the two can be unified when #197 lands.