Repository navigation
feat(hooks): add add_context builtin for dependency-free template context injection - #4206
Merged
Merged
Conversation
…text injection Adds a new add_context builtin hook that renders Go text/template arguments against hook input and joins non-blank results as additional_context. No external dependencies (no jq, no shell) are required. - Renders each arg as an independent text/template against the hook input - Joins non-blank results with newlines as additional_context - Strict: template parse and execution errors propagate and follow on_error - Plain-text output only; no re-evaluation or command execution - Registered alongside existing builtins in pkg/hooks/builtins Updates schema descriptions, types.go comments, hooks reference docs, tips guide (updates session ID tip from jq command to add_context builtin), canonical examples/hooks.yaml, and adds standalone examples/context_hooks.yaml. Unit and runtime test coverage included.
docker-agent
reviewed
Sep 9, 2026
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
🟢 No issues found — LGTM! View logs.
trungutt
approved these changes
Sep 9, 2026
social4hyq
pushed a commit
to social4hyq/homebrew-core
that referenced
this pull request
Sep 20, 2026
docker-agent 1.137.0
Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`
---
Created with `brew bump-formula-pr`.<details>
<summary>release notes</summary>
<pre>This release removes the `session_plan` toolset, adds audio/video/image input and output capability handling, expands hook functionality with new builtins and sequential pipelines, and includes several bug fixes and safety improvements.
## Breaking Changes
- Removes the `session_plan` toolset, including its tool handlers, stream event, plans service, TUI `/plans` browser, and `--session`/`--scope` addressing on the `plans` command
## What's New
- Adds detection and filtering of audio/video input modalities per request model, stripping unsupported media parts and preserving provider-specific fallbacks
- Adds `output_capabilities.image` model override to resolve image output capability from models.dev metadata
- Adds guard for image-output requests across Google (gateway, direct Gemini API, and Vertex) surfaces, rejecting incompatible custom tools and structured output before dispatch
- Adds `add_context` builtin hook for dependency-free Go template-based context injection into the model's conversation
- Adds sequential pipeline execution for `pre_tool_use`, `before_llm_call`, and `tool_response_transform` hooks, replacing the previous concurrent first-rewrite-wins strategy
- Adds 56 new safe and 27 new destructive shell safety patterns, covering Git read operations, GitHub CLI queries, Go tooling, `rg`/`ripgrep`, and common inspection commands
## Bug Fixes
- Fixes Gemini keepalive SSE events (`event: keepalive` with `data: {}`) being passed to the SDK parser, causing parse failures; these frames are now dropped at the transport layer
- Fixes image-output-capable models being incorrectly excluded from session title generation
- Fixes shell metacharacter detection and corrects `gh`/`rg` pattern classifications
- Fixes SQLite stores not being closed deterministically on Windows, causing `TempDir` cleanup failures in tests
- Fixes `pkg/session` importing the SQLite driver, keeping the package free of that dependency
## Technical Changes
- Adds request-shape diagnostics for Gemini image requests (excluding prompt, schema, media-payload, and credential fields)
- Adds shared UTF-8-safe display-name sanitization helpers
- Classifies Gemini API 400 errors into bounded actionable categories
- Adds documentation tip for injecting session ID into model context using a `session_start` hook
---
## What's Changed
* docs: update CHANGELOG.md for v1.136.0 by @docker-read-write[bot] in docker/docker-agent#4202
* fix: drop Gemini keepalive SSE events before SDK parsing by @dgageot in docker/docker-agent#4203
* feat(plan)!: remove the session_plan toolset by @trungutt in docker/docker-agent#4199
* docs: add tip for injecting session ID with a session_start hook by @dgageot in docker/docker-agent#4205
* feat(hooks): add add_context builtin for dependency-free template context injection by @dgageot in docker/docker-agent#4206
* feat(hooks): sequential pipeline for pre_tool_use, before_llm_call, and tool_response_transform by @dgageot in docker/docker-agent#4207
* feat(#3996): resolve and filter input media per request model by @aheritier in docker/docker-agent#4016
* fix(#3996): diagnose Gemini requests and sanitize API failures by @aheritier in docker/docker-agent#4017
* feat(#3996): resolve image output capability from models.dev by @aheritier in docker/docker-agent#4019
* feat(#3996): guard image-output requests across Google surfaces by @aheritier in docker/docker-agent#4020
* fix(#3996): keep image-output models eligible for session titles by @aheritier in docker/docker-agent#4021
* fix(#3996): filter gateway SSE keepalives and test image requests by @aheritier in docker/docker-agent#4022
* feat(safety): expand shell safety patterns and harden substitution checks by @dgageot in docker/docker-agent#4209
* fix(tui): close SQLite stores deterministically so Windows can delete t.TempDir by @aheritier in docker/docker-agent#4210
**Full Changelog**: docker/docker-agent@v1.136.0...v1.137.0
</pre>
<p>View the full release notes at <a href="https://github.com/docker/docker-agent/releases/tag/v1.137.0">https://github.com/docker/docker-agent/releases/tag/v1.137.0</a>.</p>
</details>
<hr>
See merge request: Harmonybrew/homebrew-core!18818
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.
The existing way to inject hook-derived context into the model's conversation requires an external tool such as
jqto parse the JSON payload on stdin and format the output. This is fragile in environments wherejqis absent, and it forces users to write shell quoting around Go template-style strings.add_contextis a new builtin hook that takes a list of Gotext/templatestrings asargs, renders each one against the typed hook input (using Go field names like.SessionID,.AgentName,.Cwd), and joins non-blank results with newlines intoadditional_context. No shell, no JSON parser, no external binary. Template parse and execution errors are strict: they discard the hook's output and follow the configuredon_errorpolicy. Rendered output is plain text only; it is not re-evaluated or executed.The tips guide's session-ID example, which used a
jqcommand hook, is updated to useadd_contextinstead. A new standaloneexamples/context_hooks.yamlshows the builtin in action;examples/hooks.yamlgains a matching entry. Schema descriptions andtypes.gocomments are updated to document the new builtin. Unit tests cover template rendering, blank-result filtering, and error propagation; a runtime integration test covers the end-to-end path through the hooks engine.