test(agents): add failing regression for LLMAgent's collapsed D-9 global-safety signal (#195) #197
No reviewers
Labels
No labels
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Bounty
$100
Bounty
$1000
Bounty
$10000
Bounty
$20
Bounty
$2000
Bounty
$250
Bounty
$50
Bounty
$500
Bounty
$5000
Bounty
$750
MoSCoW
Could have
MoSCoW
Must have
MoSCoW
Should have
Needs Feedback
Points
1
Points
13
Points
2
Points
21
Points
3
Points
34
Points
5
Points
55
Points
8
Points
88
Priority
Backlog
Priority
CI Blocker
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
State
Completed
State
Duplicate
State
In Progress
State
In Review
State
Paused
State
Unverified
State
Verified
State
Wont Do
Type
Automation
Type
Bug
Type
Discussion
Type
Documentation
Type
Epic
Type
Feature
Type
Legendary
Type
Refactor
Type
Support
Type
Task
Type
Testing
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
cleveragents/cleveractors-core!197
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "tdd/m1-llm-tool-dispatch-shared-unsafe-signal"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds a failing-first Behave regression test proving issue #195:
LLMAgent._resolve_parent_unsafe()(src/cleveractors/agents/llm.py) returnsTruewhen EITHER this agent's ownsafe_modeconfig field isFalseOR the invocation context already carries_unsafe_mode: true-- an OR of the two ADR-2034 D-9 "global safety" legs. Every dispatch site in_execute_tool_loop()then feeds that SAMEparent_unsafevalue into both_build_ephemeral_tool_config()(the ephemeralToolAgent's ownsafe_mode) and_build_tool_context()(the ephemeral context's_unsafe_mode), soToolAgent._is_global_unsafe()'s AND of those two (corrected by PR #193 / issue #189) always sees two identical operands and collapses back to the pre-#193 OR semantics.Extends
features/llm_agent_tool_loop.feature/features/steps/llm_agent_tool_loop_steps.pywith a new scenario (tagged@tdd_issue,@tdd_issue_195,@tdd_expected_fail) and two new step definitions: an LLM agent with only its ownsafe_mode: falseset (no host ever placed in unsafe mode) and a loadedsafe_mode: falseskill bundling a non-standard resource, driving a model-issued skill tool call that attempts to read that resource, asserting the call is refused.Verified locally that removing
@tdd_expected_failmakes the assertion genuinely fail against currentdevelop(the resource read currently succeeds instead of being refused), confirming the bug is reproduced, and that the failing step raises onlyAssertionErrorso the TDD CI hook inverts it correctly.The actual fix lands separately on a
bugfix/branch per issue #195.Verification
nox -s lint- greennox -s format -- --check- greennox -s typecheck- green (0 errors)nox -s security_scan- green (0 findings)nox -s dead_code- greennox -s unit_tests- green (160 features, 3364 scenarios, 0 failed)nox -s coverage_report- 97.3% (>= 96.5% threshold)nox -s integration_tests- green (382 Robot tests, 0 failed)Test plan
@tdd_issue,@tdd_issue_195,@tdd_expected_fail@tdd_expected_failinversion makes the scenario pass with the tag restorednox -s unit_testssuite greennox -s coverage_reportCloses #194
Refs #195
PR Review: !197 (Ticket #194)
Verdict: Approve
Test-only TDD capture PR, executed exactly as issue #194 prescribes. I independently verified the failing-first property locally: with
@tdd_expected_failremoved in a throwaway worktree, the new scenario fails withAssertionError(No ToolMessage found with content containing 'global safety is true'), with the ToolMessage showing[SKILL_RESOURCE_READ]📄 Skill: pdf-processing | Resource: fixtures/sample.pdf | Size: 14 chars ... sample fixture— i.e. the non-standard resource read currently succeeds through the real LLM-agent dispatch path, reproducing bug #195 for the right reason. The failing step raises onlyAssertionError, so theTddExpectedFailPolicyinversion handles it correctly, and the stale-tag guard (inverted == 0check) is genuinely exercised. With the tag restored:lint,format -- --check,typecheck(0 errors),unit_tests(160 features / 3364 scenarios), andcoverage_report(97.3%) all verified green locally, matching the reported results. (integration_testsrelied on the reported 382-test green run — a Behave-only change cannot affect the Robot suite.) No gism0 MCP tools were available in this session, so the ticket memory journal was not consulted; issues #194/#195 were read directly from Forgejo instead.The PR correctly implements only the test capture: the actual fix (deriving the ephemeral ToolAgent's
safe_modeand_unsafe_modeindependently across all three_execute_tool_loopdispatch sites) is deliberately deferred to thebugfix/branch per issue #195, so the absence of a fix is not counted against this PR. No prior review comments or author responses exist on the PR, so nothing needed to be dropped as out-of-scope from the discussion.Critical Issues
None.
Major Issues
None.
Minor Issues
None.
Nits
features/llm_agent_tool_loop.feature:211-212 — refusal assertion omits the requested resource name. Spec §4.4.8 requires the execution error to name "both safety states and the requested resource"; the sibling direct-
ToolAgent#189 scenarios infeatures/agent_skills.feature(lines 708-727, 760-777) also assertnon-standardandfixtures/sample.pdf. Adding one more assertion (e.g.And the messages list should contain a ToolMessage with content containing fixtures/sample.pdf) would pin the full spec-mandated message shape on the LLM-dispatch path too. Optional; can be folded into the fix PR for #195.Regression pins only the primary dispatch site. The scenario exercises the main-loop dispatch (~
llm.py1376-1395); the budget-retry (~1221-1230) and stuck-model-retry (~1544-1553) mirrors remain unpinned by this failing-first test. This is compliant with issue #194's acceptance criteria (one scenario required), and issue #195's fix criteria already mandate updating all three sites and auditing scenarios that rely on the collapsed signal — noting it only so the fix PR's coverage of the two mirror sites isn't assumed from this scenario alone.Summary
A clean, minimal, single-commit TDD capture that does precisely what issue #194 specifies: a
type: llmagent with only its ownsafe_mode: false(no host-level unsafe signal anywhere in the invocation context —_execute_tool_loopis invoked with no context argument), a loadedsafe_mode: falseskill bundling a non-standard resource, and a model-issuedskilltool call reading it, asserting the refusal signature (global safety is true,skill safety is false) that matches the corrected §4.4.8 / ADR-2034 D-9 AND-gate and the refusal messages emitted attool.py1395-1401/1456-1461. Implementation details check out against production code:_loaded_skillsis the realSkillLoader-injected config key (llm.py994), the mock's{"skill_name", "resource"}args match_SkillToolRequestparsing (tool.py215), andSkillResourceClassifier.classify(...).valueproduces"non_standard", matching_SKILL_NON_STANDARD_CLASS. Both new step definitions follow the file's existing conventions exactly. Tag combination satisfiesTddExpectedFailPolicyvalidation; commit first line and branch name match issue #194's Metadata exactly; the branch merges cleanly into currentdevelop. One heads-up for the follow-up fix PR (already covered by #195's acceptance criteria, not an issue here): the pre-existing #115 scenario in this same feature file ("LLM agent with safe_mode false successfully writes a file...") asserts the collapsed-signal behavior and will need updating once the gate is derived independently. Approve.d02a7984c26d2750e895Thanks for the review and the independent verification, @hurui200320.
What was done
Nit 1 — refusal assertion omits the requested resource name
Confirmed valid against the spec before touching anything:
docs/index.md§4.4.8 states "the operation MUST fail with an execution error naming both safety states and the requested resource" (same wording carried indocs/adr/ADR-2034-skill-package-support.md's D-9 text anddocs/actor-registry-standard.md§16.1). The scenario only asserted the two safety-state substrings and omitted the resource path, unlike the sibling direct-ToolAgent#189 scenarios infeatures/agent_skills.feature(lines 708-727, 760-777), which assertnon-standard,global safety is ...,skill safety is ..., andfixtures/sample.pdf.Applied exactly the fix you suggested: added
And the messages list should contain a ToolMessage with content containing fixtures/sample.pdf, reusing the existing generic assertion step — no new step definition and no production code change, sinceToolAgent._skill_tool's refusal message already names the resource (tool.py~1395-1401). Re-verified locally that the untagged scenario still fails with the sameAssertionErrorat theglobal safety is truestep (the new assertion is simply never reached while the bug is present, since Behave stops at the first failing step), and that all scenarios in the feature file pass with@tdd_expected_failrestored.Nit 2 — regression pins only the primary dispatch site
Not changed, per your own scoping: you noted this "is compliant with issue #194's acceptance criteria (one scenario required)" and is a heads-up for the follow-up fix PR's test coverage of the two mirror sites, not an issue with this PR. Agreed, and issue #195's own acceptance criteria already call for auditing/updating all three dispatch sites in the fix — left for that PR.
Heads-up on the pre-existing #115 scenario needing a future update
Not changed here either — you flagged this explicitly as a note for the follow-up fix PR (once the gate is derived independently, that scenario's assertions will need revisiting), not an action item for this test-capture PR. No change made.
Other notes
developadvanced in the meantime with an unrelated commit (issue #191, D-11 skill safe-mode/resource consistency validation). The branch was rebased onto it; confirmed that commit touches onlySkillValidator/skill_schema.pyand feature files unrelated to this scenario, and does not interact with it (this scenario injects_loaded_skillsdirectly, bypassingSkillValidatorentirely, and its skill fixture already declaressafe_mode: false, outside D-11's trigger condition in any case). Re-ranlint,format -- --check, andtypecheckagainst the rebased branch — all green. Nosrc/files changed in this update, so the previously-reported full-suitecoverage_report(97.3%),security_scan,dead_code, andintegration_tests(382/382) results remain valid; also re-confirmed via a feature-scopedunit_testsrun (all 37 scenarios infeatures/llm_agent_tool_loop.featurepass).Commit was amended in place (not a new commit) and force-pushed to this same branch, per the project's single-commit-per-issue convention; commit message updated to document the above.