You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(hooks/runtime): simplify approval plumbing and trim docstrings
Pure cleanup pass over the two preceding feature commits. No features
removed, no public API changes.
* `LocalRuntime.runTool` now returns `toolApprovalOutcome` directly,
so callers don't repeat `stop, msg := runTool(); return outcome{...}`
in seven places.
* Local `runTool` closure in `processToolCalls` is renamed to `invoke`
(no more shadowing the method) and extracted into a new
`toolInvoker` helper for clarity.
* `executeWithApproval` and `askUserForConfirmation` now `return invoke()`
in every approval path \u2014 every one of those paths used to be a
two-line tuple-unpack-and-pack.
* `processToolCalls` synthesised-error loops are extracted into a
`synthesizeRemaining` closure and wrapped in a `switch` with
`canceled`/`stopRun`/`default` arms so the control flow is visible
at a glance.
* `loop_detector`: inline `parseLoopDetectorArgs`; replace the
per-call `map[string]struct{}` exempt set with `slices.Contains`
over a slice (no allocations on the hot path); shorter state field
names (`sig`, `count`).
* `max_iterations`: inline `parseMaxIterationsArgs`; collapse the
`(int, bool)` parse-result into a single `limit\u003c=0\u200a\u2192\u200ano-op` check.
* `json.go`: previously held `canonicalJSON` and `joinNonEmpty`
helpers that were already deleted as unused; the file is now just
`sortKeys` + `canonicalToolInput`.
Trimmed the verbose comments added in the previous two commits to
match the surrounding house style. The contract is the same; the
prose just earned its keep:
* `emitHookDrivenShutdown`, `executeBeforeLLMCallHooks`,
`executeSessionEndHooks`, `loopDetectorExemptTools`, the
`maxConsecutive` normalisation block, the `builtinsState` field
comment.
* Package doc and `State` / `Register` / `AgentDefaults` doc in
pkg/hooks/builtins.
* `hooks.EventPostToolUse`, `hooks.EventBeforeLLMCall`, and
`hooks.DecisionBlockValue` docs.
9 files changed, 238 insertions(+), 395 deletions(-)
Lint clean. `go test ./...` and `go test -race ./pkg/hooks/...
./pkg/runtime/...` all pass.
Assisted-By: docker-agent
0 commit comments