Skip to content

fix(skills): a peer refusal says a mention trips it and how to send one, never to widen a grant (#3949) - #4070

Merged
vybe merged 4 commits into
devfrom
feature/3949-peer-refusal-text
Oct 29, 2026
Merged

vybe merged 4 commits into
devfrom
feature/3949-peer-refusal-text

Conversation

@webmixgamer

@webmixgamer webmixgamer commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The abilityai/trinity-enterprise#662 peer check finds a library skill's /name anywhere in a message, so a peer that only mentions the skill is refused 403 skill_not_granted. The refusal used to end "An instance admin can grant it in 's Permissions panel". The delegation contract tells the calling model to do what a retryable: false refusal says, so the remedy it offered for a string match in prose was to widen a standing permission.

  • The refusal now says:

    • nothing was delivered;
    • which skills, caller and agent are involved;
    • that a mention can be sent by writing the name without the leading slash;
    • that the skill's steps must not be carried out another way, and that asking for it by name without the slash is the same request and is not permitted.
      The grant sentence is removed. Names stay slash-free, because the text lands in execution rows and replies.
  • Text only. These are unchanged:

    • the matcher (find_gated_invocations);
    • the 403 skill_not_granted decision and retryable: false;
    • the context-text scan;
    • the audit row.

    A message that only mentions a library skill is still refused. A narrower peer matcher waits for abilityai/trinity-enterprise#925. That matcher, and the drift report counting mentions as uses, are tracked in Peer skill check: a slashed mention is still refused, and the drift report offers Grant for mentions (follow-up to #3949) #4071 (ruling recorded on A peer dispatch that only MENTIONS a library skill with a leading slash is refused 403 skill_not_granted — the match-anywhere rule is terminal on the ent#662 path #3949).

New text, one skill:

Not run, nothing was delivered: this message names the skill quarter-close, which agent-a may not run on agent-b (it was assigned from the skills library and needs a grant). If you only meant to mention it, write its name without the leading slash and send again. Do not carry out its steps another way. Asking for it by name without the slash is the same request and is not permitted.

Several skills: "names the skills a, b, which … (they were assigned … and need a grant). If you only meant to mention them, write their names without the leading slashes … their steps … Asking for them by name without the slashes …"

Changes

  • src/backend/services/peer_skill_policy.py: the refusal f-string in enforce.
  • tests/unit/test_ent662_peer_skill_surface.py: section 10 adds 8 tests:
    • the exact text in singular and plural;
    • no grant or Permissions line;
    • no slash before any name;
    • the detail still names skills, caller and agent;
    • the execute_task backstop (fan-out SKIPPED row) carries the same text.
  • docs/memory/learnings/2026-10-28-refusal-text-is-a-model-instruction.md: the review's learnings fragment.
  • docs/user-docs/collaboration/agent-permissions.md: one sentence saying a message that only mentions a library skill with a leading slash is refused too, and writing the name without the slash delivers it.

No DB migrations and no frontend change. No other doc or MCP description quotes the refusal.

Test Plan

  • cd tests && pytest unit/test_ent662_peer_skill_surface.py -p no:randomly passes 43. Before the fix, 6 of the new tests were red on the old wording. The 2 no-slash tests were already green, as a regression guard.
  • Existing ent#662 tests are unchanged and green, including "please run /x" and "/a then /b" still being refused. The neighbouring gate suites (test_ent751_*, test_3274_gate_context, test_ent753_gate_storage, the bug(gates): a held gated message is replayed to the agent in later history — it can act on a never-approved request #3402 held-row suites) are green too: 262 tests in total.
  • /verify-local --skip-agent:
    • Backend image built and the in-image import main smoke test passed.
    • Boot, health and test preflight passed.
    • Integration: 69 passed, 13 skipped, 2 known false-fails excluded.
    • Unit stage: 30,524 passed and 3 failed. Its "fail" is the known TRINITY_DEFAULT_SYSTEM_MANIFEST=disabled export artifact in test_3262_admin_username_owner.py. That file passes 10/10 without the variable and fails the same 3 with it.
  • Manual API check on localhost, with two agents, an agent_permissions edge A → B and a library skill assigned to B with no grant:
    • A's message that only mentions /<skill> → 403 skill_not_granted with the exact new text: no grant line and no slash before the name.
    • The same message without the slash → accepted.

Fixes #3949

🤖 Generated with Claude Code

webmixgamer and others added 2 commits October 28, 2026 17:24
…ne, never to widen a grant (#3949)

The ent#662 peer check reads a library skill's `/name` anywhere in the
message, so a peer that only MENTIONS the skill is refused 403
skill_not_granted. The refusal then told the calling model, which the
delegation contract instructs to "do what it says" on retryable:false,
that an instance admin can grant it in the caller's Permissions panel:
the remedy for a string match in prose was to widen a standing
permission.

The refusal now says nothing was delivered, names the skills, caller and
agent, says how to send a mere mention (drop the leading slash) and that
the skill's steps must not be carried out another way. The grant
sentence is removed. Names stay slash-free, since the text lands in rows
and replies.

Text only: the matcher, the 403 skill_not_granted decision,
retryable:false, the context-text scan and the audit row are unchanged.
A narrower peer matcher waits for Abilityai/trinity-enterprise#925.

Refs #3949

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a mention is refused too (#3949)

With several names the refusal now reads "write their names without the
leading slashes". The user doc for agent permissions adds one sentence:
a message that only mentions a library skill with a leading slash is
refused too, and writing the name without the slash delivers it.

Refs #3949

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@webmixgamer
webmixgamer requested a review from vybe October 28, 2026 18:47
…model (#3949)

Review fragment for PR #4070: when a heuristic can trigger a refusal,
its remedy must cover the false-positive case and never point at
widening authority, because MCP callers are told to do what a
retryable:false refusal says.

Refs #3949

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@dolho dolho 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.

/review: no critical issues, approving

The tests run the changed text: 43/43 pass, and with the old f-string restored 6 of the 8 new tests fail, as the PR says. The execute_task backstop test covers the fan-out SKIPPED row too. CI is green.

Two informational notes, both text-only, so both fit the #3949 ruling:

I1. The refusal now explains how to get around the gate, including when the request was real.
The same text goes to a peer that really asks for the skill, for example please run /pay-invoice. The matcher only fires on a slash (_BEFORE = r"(?<![a-z./])/" in utils/skill_invocation.py), and its docstring says plain prose is not a boundary (that is the in-container hook, trinity-enterprise#752). So "write its name without the leading slash and send again" tells the refused model that run pay-invoice gets through. "Do not carry out its steps another way" stops the caller from doing the work itself, but not from asking the callee by bare name. Suggest one more sentence, e.g. "Asking for it by name without the slash is the same request and is not permitted."

I2. "This message names…" is wrong when the match came from context_text.
enforce also scans context_text (peer_skill_policy.py:118, e.g. the MCP key name, which test_a_name_hidden_in_the_context_text_is_read_too covers). There, removing the slash from the message changes nothing, so the advice sends the model into pointless resends. Suggest different wording when the names come only from the context text, plus a test that pins the refusal text on that path.

🤖 Generated with Claude Code

…is the same request (#3949)

Review note I1 on PR #4070: "write its name without the leading slash
and send again" also tells a peer that really meant to run the skill how
to get past the dispatch-time check, which only fires on a slash. "Do not
carry out its steps another way" stopped the caller doing the work
itself, not asking the callee by bare name. The refusal now adds "Asking
for it by name without the slash is the same request and is not
permitted." (plural: them / slashes). Text only, like the rest of #3949.

Refs #3949

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@webmixgamer

Copy link
Copy Markdown
Contributor Author

Thanks @dolho. Both notes are addressed below.

I1: fixed in 12f2a4b. The refusal now ends with "Asking for it by name without the slash is the same request and is not permitted." The plural form is "Asking for them by name without the slashes …". The exact-text tests (singular, plural, and the execute_task backstop row) pin it; all 4 of them failed before the code change and pass after. Like the rest of #3949 this is text only: the dispatch-time check still fires only on a slash. Real enforcement against a bare-name request is abilityai/trinity-enterprise#925.

I2: no change, because a real peer cannot reach this path. For a peer, the context text holds only two values (skill_gate_service.requester_context_text):

  • the MCP key name. For a peer this is the platform-generated agent-<name>-key (db/mcp_keys.py:213). There is no route that renames it, and an agent name cannot contain a slash. A user-named key cannot become a peer, because resolve_source_agent honours X-Source-Agent only for an agent key naming itself or for the event loopback, so that requester stays a person.
  • the requester email, which would have to start with a slash.

Only the synthetic "MCP key name: /pay-invoice" in test_a_name_hidden_in_the_context_text_is_read_too gets there. I'd rather not add a second wording branch for a case that cannot happen. If the context-text scan changes on the peer path, the narrower-matcher work in #4071 is where to revisit it.

The ent#662 and neighbouring gate suites pass (133). CI is re-running on the new head.

@vybe
vybe merged commit bb6c5fa into dev Oct 29, 2026
25 of 26 checks passed
@webmixgamer
webmixgamer deleted the feature/3949-peer-refusal-text branch October 30, 2026 13:05
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.

3 participants