Skip to content

fix(guard): allow Agent/Task dispatch on prompt+hard steps - #94

Merged
5uck1ess merged 3 commits into
mainfrom
fix/tri-bug
Apr 17, 2026
Merged

fix(guard): allow Agent/Task dispatch on prompt+hard steps#94
5uck1ess merged 3 commits into
mainfrom
fix/tri-bug

Conversation

@5uck1ess

Copy link
Copy Markdown
Owner

Summary

  • The guard's prompt+hard allowlist excluded Agent/Task, so tri-review / tri-debug / tri-security / tri-dispatch workflows couldn't hand off to external-model subagents even though their prompts instruct the calling model to do exactly that.
  • Commit 7b5fd2b added the DISPATCH, DO NOT ANSWER preamble; this PR makes the guard actually permit the dispatch.
  • Write / Edit / Bash / WebFetch remain blocked on prompt+hard so the main Claude model cannot fabricate a review by writing the verdict itself — determinism is preserved, tri-* keeps its multi-model property.

Changes

  • src/cmd/guard.go — add Agent and Task to the prompt+hard allowlist (+12 lines, including an inline comment that documents the anti-cheat rationale and flags that subagent tool calls re-enter the guard with the same session state).
  • src/cmd/guard_test.go — flip the prior prompt+hard+Task → block case to → allow (subagent dispatch) and add a matching prompt+hard+Agent → allow case. Anti-cheat tests (prompt+hard+Write/Edit/Bash/WebFetch → block) are untouched and still pass.

Test plan

  • make test — 359 tests pass across 6 packages, 0 failures
  • go vet ./... — clean
  • gofmt -l . — clean
  • Anti-cheat verification: prompt+hard+Write → block, prompt+hard+Edit → block, prompt+hard+Bash → block, prompt+hard+WebFetch → block all still pass
  • Manual: run /devkit:tri-review end-to-end on a real diff to confirm Codex/Gemini dispatch succeeds. If the subagent's own Bash call (to hit codex-companion.mjs / gemini-companion.mjs) is also blocked by this guard because it re-enters with the same session state, a follow-up will add transcript_path-based subagent detection.

Caveat

This fix unblocks the main-agent → subagent dispatch layer. If subagent tool calls hit the same guard with the same session state, their Bash calls may still block. The fix above is intentionally minimal; the subagent-context-detection work is a separate concern and can be added without reverting this change.

Tri-* workflows (tri-review, tri-debug, tri-security, tri-dispatch)
instruct the calling model to hand off to an external-model subagent so
the verdict isn't written by Claude itself. Commit 7b5fd2b fixed the
prompt text to say "DISPATCH, DO NOT ANSWER"; the guard still blocked
the Agent/Task tool that the instructions require, so the whole dispatch
path was dead.

Add Agent and Task to the prompt+hard allowlist. Write/Edit/Bash remain
blocked so the main model cannot cheat by fabricating a review — it
must go through a subagent whose tools are independently gated.
Mirror the Go-level guard_test.go change: flip prompt+hard+Task from
expect-block to expect-allow, add prompt+hard+Agent → allow. Keeps
the shell smoke suite in sync with the Go unit tests.
Three findings from pr-review-toolkit (2026-04-17):

- test-analyzer: pin command+hard+Agent/Task as block so a future
  refactor can't silently extend the prompt carve-out to command
  steps (dispatch is a prompt-step privilege; command steps are
  engine-driven).
- test-analyzer: add prompt+hard+Edit and prompt+hard+WebFetch to
  the shell smoke suite — the PR body names these as anti-cheat
  must-holds, the Go suite had them but the shell mirror did not.
- comment-analyzer: drop the guard.go comment's final sentence
  recommending enforce: soft as the escape hatch for subagent tool
  needs. That workaround would also unlock the main agent's
  Write/Edit/Bash, which is exactly what this PR is designed to
  prevent. Keep the re-entry note (verified accurate by the
  silent-failure reviewer).
@5uck1ess
5uck1ess merged commit e85f14d into main Apr 17, 2026
6 checks passed
@5uck1ess
5uck1ess deleted the fix/tri-bug branch April 17, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant