fix(terminal): propagate HERMES_KANBAN_BOARD to subprocess env to prevent board mis-routing#36742
Open
CryptoByz wants to merge 1 commit into
Conversation
…vent board mis-routing
tonydwb
approved these changes
Jun 1, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
✅ Looks Good
- Well-documented fix: PR body comprehensively explains the race condition between
kanban_*tools andharness kanbanCLI shell-outs targeting different boards - Clean implementation: New
_inject_context_kanban_boardhelper bridgesHERMES_KANBAN_BOARDinto subprocess env for both foreground (_make_run_env) and background (_sanitize_subprocess_env) processes - No-op when already present: Gracefully handles dispatcher worker path where env var already propagated from
os.environ - Exception handling: Wrapped in
try/except passfor robustness on import failure - Addresses real issue: Solves a genuine race where concurrent
boards switchcould cause tool-created tasks to become invisible to CLI calls in the same turn (#20074)
Reviewed by Hermes Agent
mxnstrexgl
approved these changes
Jun 1, 2026
mxnstrexgl
left a comment
There was a problem hiding this comment.
🤖 Automated PR Review
Security Scan
- ✓ No hardcoded secrets, injection sinks, unsafe deserialization, or dependency red flags found by this automated scan.
Code Quality
- ✓ No blocking code-quality issues found by this automated scan.
- ℹ️ No test file changes detected; verify existing coverage exercises this behavior.
Summary
Status: APPROVE — security findings: 0, quality suggestions: 0.
Automated review; raw diff content intentionally omitted.
11 tasks
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.
Fixes #20074
Problem
When an agent uses
kanban_*tools andharness kanbanCLI shell-outsin the same turn, the two operations can silently target different boards.
The
kanban_*tools resolve the active board viaget_current_board(),which checks
HERMES_KANBAN_BOARDenv first (set by the dispatcher onworker spawn). The terminal tool's subprocess does not inherit this env
var — it falls back to reading
<root>/kanban/currentfrom disk. If aconcurrent session runs
hermes kanban boards switchbetween thekanban_*call and the shell-out, that disk file changes and the CLItargets a completely different board. Tasks created by the tool call
become invisible to the CLI call in the same turn.
Root cause
_sanitize_subprocess_envand_make_run_envintools/environments/local.pyalready bridgeHERMES_HOMEintosubprocess env via
_inject_context_hermes_home. There was noequivalent bridge for
HERMES_KANBAN_BOARD, so the board pin set bythe dispatcher — or implied by
kanban/currentat turn start — wasinvisible to any shell-out the agent made.
Fix
New helper
_inject_context_kanban_boardintools/environments/local.py, called from both_sanitize_subprocess_env(background processes via
process_registry) and_make_run_env(foreground commands):
HERMES_KANBAN_BOARDis already present in the sanitized env(propagated from
os.environby the dispatcher worker path), thefunction is a no-op — no double-write, no override.
get_current_board()and injects the result,pinning the subprocess to whichever board was active at the moment
_make_run_env/_sanitize_subprocess_envran — the same boardthe
kanban_*tools would use in the same turn.defaultboard is not injected (it is the implicit fallback andneeds no explicit pin).
What this does NOT change
HERMES_KANBAN_BOARDisabsent and
get_current_board()returnsdefault, so nothing isinjected.
HERMES_KANBAN_BOARDinos.environ, which_sanitize_subprocess_envcopies before thisfunction runs. The function detects the existing value and exits early.
construction paths not touched by this PR. A follow-up can add the
same bridge there if needed.
Test plan
Verified manually: with
HERMES_KANBAN_BOARD=myboardset on the agentprocess,
subprocess.run(["env"], capture_output=True)in the terminaltool now shows
HERMES_KANBAN_BOARD=myboard. Without the fix, the varwas absent from subprocess env.