diff options
| author | Drew Ritter <drew@ritter.dev> | 2026-11-02 12:47:05 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-02 12:47:05 -0800 |
| commit | d77032086f56ca7cdcacda05be96d610dfd42789 (patch) | |
| tree | c34c55f07f825f4be41b1cddbf5a6acc56524623 | |
| parent | 352652109f3166b6e785d67ce991f4da45041b3e (diff) | |
| parent | 76b0f89deca5187475e66ad5f63054c22da41bec (diff) | |
Merge pull request #2596 from obra/fix/2536-hermes-child-bootstrap
fix(hermes): skip the controller bootstrap for delegate_task children (#2536)
| -rw-r--r-- | .hermes-plugin/__init__.py | 6 | ||||
| -rw-r--r-- | tests/hermes/test_plugin.py | 18 |
2 files changed, 22 insertions, 2 deletions
diff --git a/.hermes-plugin/__init__.py b/.hermes-plugin/__init__.py index 7d4e1f5..3c5a207 100644 --- a/.hermes-plugin/__init__.py +++ b/.hermes-plugin/__init__.py @@ -108,7 +108,9 @@ def register(ctx): # pre_llm_call returning {"context": ...} is the documented injection path # (on_session_start return values are ignored, and ctx.inject_message # refuses from that hook — verified empirically 2026-07-23). The context is - # appended to the first turn's user message. + # appended to the first turn's user message. delegate_task children run + # with platform="subagent" and an empty history, so every child's first + # turn would otherwise get the controller bootstrap too. def pre_llm_call( session_id=None, user_message=None, @@ -118,7 +120,7 @@ def register(ctx): platform=None, **kwargs, ): - if is_first_turn: + if is_first_turn and platform != "subagent": return {"context": bootstrap} return None diff --git a/tests/hermes/test_plugin.py b/tests/hermes/test_plugin.py index 57d619e..7c896a3 100644 --- a/tests/hermes/test_plugin.py +++ b/tests/hermes/test_plugin.py @@ -87,6 +87,24 @@ class TestBootstrapInjection: assert _fire_pre_llm(mock_ctx, is_first_turn=False) is None assert _fire_pre_llm(mock_ctx, is_first_turn=None) is None + def test_subagent_platform_skips_bootstrap_on_first_turn(self, mock_ctx): + plugin = _load_plugin() + plugin.register(mock_ctx) + assert ( + _fire_pre_llm(mock_ctx, is_first_turn=True, platform="subagent") + is None + ) + + def test_non_subagent_platforms_receive_bootstrap(self, mock_ctx): + plugin = _load_plugin() + plugin.register(mock_ctx) + for platform in ("cli", "desktop", "cron", "telegram"): + result = _fire_pre_llm( + mock_ctx, is_first_turn=True, platform=platform + ) + assert isinstance(result, dict) + assert BOOTSTRAP_MARKER in result["context"] + def test_hook_tolerates_future_kwargs(self, mock_ctx): plugin = _load_plugin() plugin.register(mock_ctx) |
