Skip to content

fix(taskrunner): steer the in-band host-deny notice before every reject - #15372

Merged
bolichen97 merged 1 commit into
mainfrom
fix/deny-notice-task-exec-5403
Oct 2, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/deny-notice-task-exec-5403

Conversation

@CrysisDeu

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A tool call the task runner refuses on the HOST's behalf is explained to the model as a host deny, never as "user denied".

Slice 3 of #5403. On the task runner (task_executor.py step turns, task_planner.py decomposition turn) every host deny -- a PreToolUse hook block, a stored-hook deny, the unattended run's deny-by-default, the planning phase's no-hook-store deny -- went straight to reject_tool, so the model read kiro-cli's fixed "User denied tool execution" for a refusal the person never made, and abandoned or routed around a call nobody objected to. Slice 1 (#14141, llm_helpers) and slice 2 (#15083, the messaging surfaces) already steer the shared in-band notice before their rejects; the task runner did not.

Why it matters

Autonomous projects and cron-launched runs are exactly the surfaces with no human watching. A model told "the user denied this" in an unattended run has nobody to ask, so it silently drops the step or works around the policy -- and the transcript looks like a model that gave up, not a host that refused.

Not a goal

  • The remaining In-band deny notice: host denies on surfaces other than the chat runner still say "user denied" #5403 surfaces (eval/*, subagent*, dashboard/handlers/*, auto_improvement/spine/agent_runner.py) -- later slices; the issue stays open.
  • Splitting permission_pre_tool_block's one block string into "delivered deny" vs "gate fault" causes (hooks.py is unchanged; the chat runner steers the same BLOCKED: strings as policy).
  • Telling apart the interactive handler's False provenances (a human's Deny vs the dashboard prompt expiring): the callback returns a bare bool on every surface, and slice 1 records the same result as the one allowlisted user rejection.
  • An end-of-turn recovery continuation for the task runner (the chat runner's _refusal_notices fallback): the steer is the mechanism, the continuation a dashboard-only fallback.

What changed (motivation → approach → change)

Symptom → cause: four reject_tool( sites on the task runner answered the wire with nothing steered first, so the only explanation the model ever saw was the harness's generic string.

Approach: reuse the shared helper rather than build a fourth notice. llm_helpers._steer_host_deny (redact, forward to deny_notice.steer_refusal_notice, answer the wire through an orphan reject if cancelled mid-steer) is what channel.py already reuses; the cancellation shape here is the same (a timed step turn on a shared ACP pipe). The cause vocabulary is the existing one -- no new DENY_CAUSE_*.

Change, per site (enumerated; test_taskrunner_deny_notice.py fails on a site missing from this list):

task_executor.py -- ONE funnel, _reject_and_log, now with a REQUIRED keyword cause: str | None. A DENY_CAUSE_* name steers before the reject; None is the explicit "not a host deny" and stays bare. There is no default to inherit the wrong answer from. The stored-hook TOOL_DENY site, which rejected inline, now goes through the funnel with its exact SEL row shape (outcome="denied", error="hook_deny") via new outcome/error kwargs, so the module has exactly one wire reject.

site verdict cause reason steered
agent-spec PreToolUse gate blocked (spec_hook_deny) host policy the gate's block string (a delivered deny, or a gate with no verdict: unreadable spec, hook could not run) -- as chat_runner._reject_hook_blocked steers the same strings
stored hooks TOOL_DENY (hook_deny) host policy tool_result.reason
unattended deny-by-default (headless_no_authorization) host surface_policy "this task run is unattended: no approval handler is attached and no hook auto-approve trusts this tool, so only tools listed in hooks.auto_approve_tools can run here"
interactive handler said no (interactive_rejected) user None -- (kiro-cli's wording is the truth; "NOT a user action" would be a lie)
mid-stream compaction (context_overflow) teardown None -- (the turn is abandoned and re-run after compact(); there is no continuing turn for a notice to correct)

task_planner.py -- two inline sites, audit → steer → reject:

site verdict cause reason steered
stored hooks TOOL_DENY during decomposition host policy hook_result.reason
no hook store (no_hook_store) host surface_policy "the planning phase runs no tools: it only decomposes the spec into steps and has no hook store to gate a tool call, so every call is refused here"

surface_policy (not policy) for the two deny-by-default sites because the policy notice appends class remediation keyed off the reason and the model's own title; on a surface where nothing can approve the call, naming a sanctioned command would be a second wall (same reasoning as slice 1's reject-all / read-only sites).

Audit order: the SEL row is now written BEFORE the steer and the reject at every site (previously _reject_and_log rejected first, then logged). The steer is one more bounded await on the ACP pipe; a backend that stops reading stdin cancels the coroutine at the turn deadline, and a row sequenced after the awaits would never be written. This is the rule every other deny surface already follows (test_deny_audit_first, test_llm_helpers_deny_notice, test_messaging_deny_notice).

Docs: docs/system-specs/common/injected-messages.md gains the task-runner paragraph under the in-band deny notice section, with the per-site table above.

Backwards compatibility

Compatible: _reject_and_log is module-private (no external caller: git grep "_reject_and_log(" outside task_executor.py finds only SubagentManager's unrelated method of the same name). Every SEL row keeps its outcome / error / metadata shape; only its position moves (before the wire). A backend without supports_refusal_steer behaves exactly as before: steer_refusal_notice returns "" and the reject runs.

Tests

test/test_taskrunner_deny_notice.py (new, 29 tests; red on origin/main @ 6d54165 -- 22 failed / 7 passed, the 7 being the no-notice negatives; mutation-checked: 11 mutants, every one killed -- steer dropped, reject-before-steer, audit-after-steer, headless cause flipped to policy, interactive rejection steered, compaction teardown steered, cause given a default, hook reason dropped, planner steer dropped, planner cause flipped, planner audit-after-steer):

  • Behavioural, driving the real execute_task / decompose with a provider double recording steer/reject ORDER: hook deny (hook's reason, policy wording), spec-gate block, unreadable-spec block, headless deny (surface wording, no remediation line), decomposition hook deny, decomposition no-hook-store; interactive rejection and compaction teardown send NO notice; backend without the capability only rejects; a raising steer still rejects; agent-authored text is redacted before it reaches the model; the SEL row lands before the steer with its original shape.
  • Source-level guards: task_executor.py has exactly one .reject_tool( and it is the funnel; the funnel audits → steers → rejects; cause is keyword-only with no default; every _reject_and_log( call matches exactly one enumerated fingerprint; host sites name cause=DENY_CAUSE_* and a reason=; user/teardown sites say cause=None; exactly one user rejection is allowlisted; task_planner.py's two rejects are each preceded by the steer with the audit before it; both modules use llm_helpers._steer_host_deny itself.

Neighbouring files run locally by path and green: test_taskrunner_autoapprove.py, test_task_planner_decompose_gate.py, test_llm_helpers_deny_notice.py.

Manual verification

N/A — unit coverage sufficient: the behaviour is the order of three awaits on a provider (audit, steer, reject) and the notice text, both asserted directly against the real execute_task / decompose loops with a recording double.

Screenshots / video

N/A — backend only, no user-visible frontend surface.

Related Issues

Fixes the task_executor/task_planner slice of #5403 (the issue stays open for the remaining surfaces). Follows #14141 (slice 1) and #15083 (slice 2).

Pattern harvest

Rule candidate: lint
Pattern: a reject_tool( on a host-deny path not preceded by the shared steer; every surface now carries a source-walking guard, and a repo-wide one (every .reject_tool( in src/kiro_crew either steers first, is inside a steer helper's orphan path, or is on an enumerated user/teardown allowlist) would close the class once the last #5403 slices land.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@CrysisDeu
CrysisDeu requested a review from a team as a code owner September 30, 2026 09:22
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of 2f7d060ed2a508bd3e0d50ccecf8ff79b17540eb — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] 2f7d060

Description read

[DESCRIPTION-READ] efa042c53bfdcc959f45a6394c9384c337f0d657e1b971376e7cb0a9ad470fd6

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 2f7d060ed2a508bd3e0d50ccecf8ff79b17540eb and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 2f7d060

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 2f7d060ed2a508bd3e0d50ccecf8ff79b17540eb: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 2f7d060ed2a508bd3e0d50ccecf8ff79b17540eb — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Verify the "red on base: 22 failed / 7 passed" claim by running test_taskrunner_deny_notice.py against origin/main; it is asserted, not CI-visible.

What this change ships

Inventory (9 items) — 8 justified

Intent: a FIX — the task runner's host refusals read to the model as "User denied tool execution", so unattended runs abandon calls nobody objected to (slice 3 of #5403; slices 1–2 are on base in llm_helpers/channel.py/messaging/driver.py).

  1. Step-turn hook and spec-gate denies now tell the model the host's real reason before rejecting — justified
  2. Unattended deny-by-default now explains what the surface permits, no remediation line — justified
  3. Decomposition hook deny steers the hook's reason — justified
  4. Decomposition no-hook-store deny explains the phase runs no tools — justified
  5. SEL audit row now lands before the wire answer at every task-runner deny site — justified
  6. Interactive rejection and compaction teardown stay bare, now pinned as cause=None — justified
  7. Spec paragraph in injected-messages.md, same commit — justified
  8. New test file enumerating every deny site with per-site verdicts — justified
  9. test_auto_approve.py double upgraded to a real ToolHookResult — rides along (required by the fix: the steer reads reason as str)

Checks run: _steer_host_deny is reused, not re-spelled (grep: one definition in llm_helpers, both new modules import it); no new DENY_CAUSE_* (constants.py unchanged); _reject_and_log has no external caller (grep test/: only SubagentManager's unrelated method); audit-first matches the pinned repo rule (test_deny_audit_first.py, test_messaging_deny_notice.py); hooks.auto_approve_tools exists (hooks.py); no deleted pin — the inline hook-deny site keeps outcome="denied"/error="hook_deny". Remaining #5403 siblings (eval/*, subagent*) are declared deferred under the open issue. Not product shape: the shape ships on base for three sibling surfaces and the spec section this extends.

[FIRST-PRINCIPLES-REVIEWED] 2f7d060

Description read

[DESCRIPTION-READ] f135081e9ed53f006cdc1297ea39b2e2f7dd6dcb63c4a185f18bdb41ffd833d9

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed 2f7d060ed2a508bd3e0d50ccecf8ff79b17540eb — this comment is updated in place on each push.

Review details

One model-facing notice states a cause that is false on a reachable branch; nothing blocks.

FINDING — src/kiro_crew/task_executor.py:88 — _HEADLESS_DENY_REASON asserts "no hook auto-approve trusts this tool, so only tools listed in hooks.auto_approve_tools can run here", but the same else branch is also reached after a hook TOOL_AUTO_APPROVE whose name_grant.refusal_for_event refusal left _auto_approved False (shadowed/unidentified program name) and after a lapsed taskrunner:{task_id}:autoapprove scoped grant, so on a cron/autonomous run the model is steered a false cause and told to fix a config key the tool is already listed in, while the withheld-grant reason never reaches it → Fix: capture _ng_refusal.log_text (and the expiry) into a local reason at those two decline sites and pass it as reason= instead of the single constant, as llm_helpers does with "the hook's name-based grant was withheld (…) and this surface has no approver".

[OPUS-REVIEWED] 2f7d060

Verdict parsed from the review's SHA-scoped output markers for commit 2f7d060ed2a508bd3e0d50ccecf8ff79b17540eb.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 2f7d060ed2a508bd3e0d50ccecf8ff79b17540eb: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 30, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/deny-notice-task-exec-5403 branch from c783801 to bb6a8c7 Compare September 30, 2026 10:43
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 30, 2026
bolichen97
bolichen97 previously approved these changes Oct 1, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved: PR Readiness passed on this head, no open change requests.

@bolichen97
bolichen97 enabled auto-merge (squash) October 1, 2026 05:59
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 1, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/deny-notice-task-exec-5403 branch from bb6a8c7 to e3bc78e Compare October 1, 2026 07:57
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 1, 2026
A host deny on the task runner still handed the model kiro-cli's fixed
"User denied tool execution". task_executor now denies through one funnel
(_reject_and_log) whose required cause= keyword is the per-site verdict: a
DENY_CAUSE_* name steers llm_helpers._steer_host_deny before the reject,
None is the explicit not-a-host-deny (the interactive handler's no, the
mid-stream compaction teardown) and stays bare. task_planner's two
decomposition denies audit, steer, then reject. SEL row first everywhere.

Fixes the task_executor/task_planner slice of #5403.
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 1, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/deny-notice-task-exec-5403 branch from e3bc78e to 2f7d060 Compare October 1, 2026 09:58
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 1, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved: PR Readiness green on this head, merges cleanly into current main, no outstanding blocking review.

@bolichen97
bolichen97 merged commit 5a3d07f into main Oct 2, 2026
97 checks passed
@bolichen97
bolichen97 deleted the fix/deny-notice-task-exec-5403 branch October 2, 2026 05:00
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 2, 2026
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.

2 participants