Skip to content

fix(runtime): deny the tool family that promises a second turn, measured on the fleet CLI (#2468) - #2476

Merged
vybe merged 1 commit into
devfrom
feature/2468-headless-tool-audit
Sep 2, 2026
Merged

vybe merged 1 commit into
devfrom
feature/2468-headless-tool-audit

Conversation

@webmixgamer

Copy link
Copy Markdown
Contributor

What

#2454 removed ScheduleWakeup. It was one member of a family: a Trinity execution is one claude --print process that exits when the model stops writing, so any tool result asserting a later event — a wakeup, a cron fire, a workflow notification, a peer message — is a false fact the model plans around and then reports success for (#2467 is the measured incident shape, now queryable via turn_integrity).

Fixes 1 and 5 of the issue shipped in #2458. This PR is fixes 2 (the audit) and 3 (the prompt counterweight), redone from the closed reference PR #2472 with the audit re-measured on the CLI the fleet actually ships (claude 2.1.235; #2472 measured 2.1.220) — and the re-measurement did real work: one membership changed, two rationales were rewritten, and the audit became a living contract instead of a dated snapshot.

The audit (AC 4) — measured on 2.1.235

Every tool offered on the headless path (30 built-ins) was judged from its OWN description read out of live runs in a fleet agent container; the deciding fragment is recorded verbatim beside each entry in _runtime_config.py. All six fragments #2472 pinned on 2.1.220 re-verified byte-identical.

Denied (11) — ScheduleWakeup, Workflow, Monitor, TaskOutput, CronCreate, CronList, CronDelete, SendMessage, ListAgents, PushNotification, RemoteTrigger.

What the re-measurement changed vs #2472:

  • ListAgents → denied (the issue's audit list named it; fix(runtime): deny the whole family of tools that promise a second turn (#2468) #2472 never classified it). One joint decision with SendMessage: it "Lists agents you can SendMessage to", verbatim including "other local Claude sessions on this machine".
  • SendMessage's rationale rewritten. 2.1.220's description was teammate-only ("no peers exist in a container" — fix(runtime): deny the whole family of tools that promise a second turn (#2468) #2472's recorded reason). On 2.1.235 it gained a genuinely working in-turn facet: continuing a spawned subagent (local_agent tasks ARE waited by claude --print — _NON_WAITED_BG_TASK_TYPES). The deny stands on different grounds: in a Trinity container, "other local sessions" are other concurrent executions of the same agent sharing one HOME (up to max_parallel_tasks, possibly different callers' turns) — an unaudited cross-execution channel outside Trinity's permissioned chat_with_agent path. The lost subagent-continuation facet is recorded as the cost; subagents themselves are untouched.
  • Workflow is offered on 2.1.235 (an earlier capture suggested absence) — all eleven denials do real work; expected post-deny count 30 − 11 = 19, confirmed live.

Kept is now DATA: PLATFORM_KEPT_TOOLS (19 names, reasons in prose — including NotebookEdit, new on 2.1.235, and the Task-list four, which sit in the init array but are not model-visible on 2.1.235) + AUDIT_CLI_VERSION = "2.1.235". DENIED ∪ KEPT exactly covers the measured init list, and the exact-cover is test-pinned. scripts/dev/audit_headless_tools.py is the living half — one command that probes a live agent (with the container's own merged deny, exactly as the spawn sites pass it) and diffs offered built-ins against the audit. It exists because --disallowedTools treats an unknown name as a silent no-op: a CLI rename re-offers the false promise with no signal, no PR workflow builds the base image, and the audited set already drifted once in fifteen patch releases. (CI enforcement needs a credentialed agent CI lacks — registered in the debt inbox.)

Noted, not swept: DesignSync (external control plane like RemoteTrigger, but no future-work promise). Tension, stated: Bash's own 2.1.235 text blocks long leading sleeps and routes polling to the denied Monitor — the counterweight names the working idiom instead.

The counterweight (fix 3)

The one promise Trinity cannot delete is Bash's own — "you will be notified when it completes" (verbatim on 2.1.235, both backgrounding variants), and no tool description can correct a different tool's description. PLATFORM_INSTRUCTIONS gains the always-tier "Nothing survives the end of your turn": the work is killed, not merely unwatched; foreground to completion; the sanctioned wait idiom (plain foreground until-loop under timeout, since long sleeps are blocked and Monitor is gone); never end a turn with work outstanding or report success for something only started; split + persist + set_reminder as the working alternative.

Two truth-scoping rules, both measured, that the blunt version would get wrong:

  • Subagents are exempt from the kill-claim — local_agent tasks are CLI-waited, so "notified when it completes" is TRUE for agents you spawn; the section says so explicitly.
  • No "there is no second turn" absolutism — resumable surfaces (Workspace/session --resume turns) do get later turns; the claim is process-scoped: a later turn is a fresh process in which your background work is already dead.

The family paragraph in "Repeating Work and Deferred Ticks" is phrased as a capability fact ("dies with this process"), never a policy fact ("the platform denies…"), so it stays true during the mixed-fleet window where this prompt reaches agents weeks before the image cut does.

Cost, measured: ≈ +390 input tokens per execution (+14.6% on the constant), every tier, every runtime. Backend-side — reaches the fleet with no image rebuild. The deny half needs one (below).

A correction to AC 2

(a --disallowedTools denial surfaces as a visible tool error in the transcript, which satisfies this)

Measured on 2.1.220 (#2472) and re-verified on 2.1.235 in this PR's live checks: it does not. The deny removes the tool from the advertised set — a prompted ScheduleWakeup call answers "I don't have access to a ScheduleWakeup tool — it's not in my available tools list." A deny leaves an absence, not a refusal. Stronger than the AC hoped (the false belief is never formed), and the AC's intent — "distinguishable afterwards" — is served twice over by the probed init list and by #2467's turn_integrity flagging. The issue's AC text is amended accordingly.

Verified live, not asserted

On this branch's rebuilt image + --reload backend (the #2467-instrumented measurement loop):

re-audit probe:        CLEAN — 19 built-ins offered, none of the 11 denied, version match
AC-2 semantics:        prompted ScheduleWakeup call → absence ("not in my available tools list")
E2E incident shape:    the exact #2467 repro instruction → the model REFUSED to background-and-abandon,
                       explained the kill semantics, offered set_reminder — clean row, no turn_integrity flag
fleet baseline:        1 flagged row before = 1 after (the pre-fix incident row only)

Claim hygiene: one run per arm — directional evidence that the incident shape is now removed-or-measurable (prevented ⇒ clean row; if a model ever complies anyway ⇒ flagged row), not proof of "counteracted". turn_integrity is the instrument either way.

Guards

tests/unit/test_2468_headless_tool_audit.py (34 tests) pins the discipline and the measured snapshot: every denied name has a recorded reason; fragments verbatim; KEPT named in prose AND data; CORE tools never denied (over-denying breaks agents silently at spawn); DENIED ∪ KEPT exactly covers the 2.1.235 init list (a version bump forces a re-measure); plain-names-only shape (no specifiers, no internal spaces); guardrails merge + dedupe (AC 5); the counterweight registered always-tier, surviving every tier and runtime, quoting the promise it contradicts, staying truthful about waited subagents, and naming the wait idiom; and the reverse vocabulary guard — every name the prompt claims removed must actually be denied (the forward direction lives in test_2454_loop_routing.py). Four mutations confirmed red then reverted (drop a denied name · deny Bash · drop a name from the prompt paragraph · drop the subagents clause).

Release coordination

Redone from closed reference PR #2472 with the version-discipline and living-contract additions; learnings entry carried (audit-by-descriptions + re-measure-on-the-version-you-ship).

Fixes #2468

🤖 Generated with Claude Code

…red on the fleet CLI (#2468)

ScheduleWakeup (#2454) was one member of a family: in a one-shot
`claude --print` execution, any tool result asserting a later event — a
wakeup, cron fire, workflow notification, peer message, desktop
notification — is a false fact the model plans around and then reports
success for (#2467 is the measured incident shape).

Fixes 2+3 of the issue (fixes 1+5 shipped in #2458), redone from closed
reference PR #2472 with the audit re-measured on claude 2.1.235 — the
CLI the fleet image actually ships. The re-measurement changed one
membership (ListAgents added; #2472 left it unclassified) and rewrote
two rationales (SendMessage: 2.1.235 gained a working in-turn
subagent-continuation facet, so the deny now stands on the unaudited
cross-execution channel between concurrent turns sharing one container
HOME; Monitor: its own text routes single waits to Bash-until anyway).

- PLATFORM_DENIED_TOOLS 1 → 11, every entry with its deciding
  description fragment quoted verbatim beside it (2.1.235-verified)
- KEPT becomes data: PLATFORM_KEPT_TOOLS (19, reasons in prose) +
  AUDIT_CLI_VERSION; DENIED ∪ KEPT exactly covers the measured init
  list (test-pinned), and scripts/dev/audit_headless_tools.py is the
  one-command re-audit for the next CLI bump (a deny of an unknown
  name is a silent no-op, and no PR workflow builds the base image)
- Always-tier prompt section "Nothing survives the end of your turn":
  counterweight for Bash's own un-deniable "You will be notified when
  it completes"; truth-scoped (subagents are waited; resumable
  surfaces get later turns) and names the working wait idiom, since
  Bash blocks long sleeps and routes polling to the denied Monitor
- Family paragraph phrased as capability fact, true on both sides of
  the image cut (the prompt reaches the fleet before the image does)
- 34 tests incl. exact-cover snapshot, reverse vocabulary guard, CORE
  never-denied; 4 mutations confirmed red; live-verified end to end
  (probe CLEAN: 19 built-ins offered; AC-2 absence semantics; the
  E2E incident shape now REFUSED by the model, clean turn_integrity)

Agent-side deny needs base-image rebuild + fleet cold recreate; the
prompt half reaches the fleet on backend deploy alone.

Fixes #2468

Co-Authored-By: Claude Fable 5 <[email protected]>
@webmixgamer
webmixgamer changed the base branch from main to dev September 1, 2026 16:54
@webmixgamer
webmixgamer requested a review from dolho September 1, 2026 17:09

@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 — structural review

Branch: feature/2468-headless-tool-audit → dev (merge-base efc6d7db)
Files: 11 (+823/−5) · Scope: CLEAN · Plan completion: AC 4 DONE, AC 5 DONE, AC 2 amended-and-served, ACs 1/3 pre-shipped in #2458 (verified still green)

Ran locally against the branch worktree: test_2468_headless_tool_audit.py + test_2454_loop_routing.py → 50 passed; the full prompt-adjacent suite (test_1402, test_1535, test_2157, test_ent243, test_platform_prompt_{unit,runtime}, test_public_channel_prompt) → 150 passed.

Critical: none. The executable surface is a data/comment change in a stdlib-only module, static prompt text, one docker-exec dev script (list-form args, shlex.quote on every composed value, bounded timeouts), tests and docs. No SQL, no auth boundary, no concurrency, no credential path.

I spot-checked three of the audit's verbatim fragments against the live 2.1.235 descriptions rather than taking them on trust — TaskOutput's <task-notification> line, Monitor's "you keep working and notifications arrive in the chat" + "runs until you call TaskStop or the session ends", and SendMessage/ListAgents' cross-session addressing. All three match, and SendMessage's own text supplies a fourth argument the audit doesn't use: "Permission boundaries are per-session: NEVER ask a peer to perform an action that was denied ... (cross-session permission laundering)" — which is precisely the concurrent-executions-share-one-HOME concern, stated by the tool itself. Worth adding to the rationale comment.

Two structural properties I want to name because they're what makes this reviewable rather than a list of names someone mistrusted: KEPT as data with an exact-cover assertion (a new tool cannot enter the offering unclassified without a red test once the version moves), and the reverse vocabulary guard (a tuple shrink can't leave the prompt asserting a deny that no longer exists). The _comment_prose inversion — testing the comments because here the prose is the deliverable — is the right call and correctly explained.

Informational

[I1] The sanctioned wait idiom self-defeats at the Bash tool's default timeout (Confidence: 7/10)
src/backend/services/platform_prompt_service.py — the counterweight's own bullet:

Wait in the foreground with a bounded loop — e.g. timeout 300 bash -c 'until <condition>; do sleep 5; done'

Bash's schema on this CLI family is "timeout is in milliseconds: default 120000, max 600000". A timeout 300 wrapper run at the default exceeds the tool timeout at 120 s and is promoted to background — which the paragraph two lines above correctly identifies as the false-promise path ("a command promoted to the background at its timeout says the same"). So the one worked example the section hands the model triggers the exact failure the section exists to prevent, roughly two thirds of the way through.

Cheapest fix is one clause: either keep the example under the default (timeout 90 …) or say to pass the Bash tool's own timeout parameter (up to 600000 ms) covering the wall. I'd take the second — the first teaches a 90-second ceiling that isn't real. Not a merge blocker: the surrounding text is correct and a model that reads the whole section will recognise the promotion when it happens.

[I2] AUDIT_CLI_VERSION has no mechanical link to the CLI the image actually installs (Confidence: 8/10)
docker/base-image/Dockerfile:78 is npm install -g @anthropic-ai/claude-code@latest, so every base-image rebuild moves the CLI, while test_denied_and_kept_are_disjoint_and_cover_the_measured_offering pins AUDIT_CLI_VERSION == "2.1.235" — i.e. the constant is asserted against itself. The exact-cover snapshot therefore stays green across arbitrarily many CLI bumps and only fires once a human has already noticed and edited the constant.

This is honestly named in the PR body and registered in the debt inbox (CI can't run the probe without agent credentials), so I'm not asking for CI here. But there is a zero-credential net available inside the image: the agent-server already shells claude on every spawn — logging one WARNING when claude --version disagrees with AUDIT_CLI_VERSION puts the drift signal in the place that always has both facts, needs no CI secret and no probe run. Worth folding into the debt entry as the cheaper first step, ahead of the /verify-local wiring.

[I3] TaskOutput's cost is unrecorded, unlike SendMessage's (Confidence: 6/10)
The audit records what denying SendMessage costs (in-turn subagent continuation) — good discipline that the TaskOutput entry doesn't repeat. TaskOutput is not purely a promise: block=true is an in-turn wait on a backgrounded task, which the deny removes. The cost is genuinely small, and the tool's own text supplies the mitigation the entry could cite — "For bash tasks: prefer using the Read tool on that output file path", and Read is kept — so background-then-read still works in-turn. One sentence, so the next reader doesn't have to re-derive it.

[I4] The counterweight is an unconditional ≈+390 input tokens on every execution, including public-channel turns (Confidence: 8/10)
prompt_tier.py:86 — _MINIMAL_PREFIXES = (), so every model resolves VERBOSE today and the always-tier placement costs the same on all paths; compose_system_prompt carries PLATFORM_INSTRUCTIONS into public-link / Slack / Telegram / x402 turns too, where a customer-facing one-liner now pays for guidance about foreground bash loops. The always-tier argument is sound (no tool description can carry a correction to a different tool's description, so there's nothing to fall back to) and the cost is stated in the PR — flagging it only so it's a recorded decision rather than a discovery when someone enables a MINIMAL family.

Clean

  • SQL / data safety — no SQL, no schema, no migration in the diff.
  • Concurrency — merged_disallowed_tools is pure over its argument; no shared state added.
  • Auth boundaries — no endpoints, dependencies or WS channels touched.
  • Credential exposure — dev script handles no secrets; --dangerously-skip-permissions is inside the container, matching the existing spawn sites.
  • Over-denial — CORE_TOOLS guard plus the disjointness assertion; Bash/Read/Write/Edit/Skill/ToolSearch/Task* all in KEPT. Confirmed the denied names are built-in-only and cannot collide with mcp__trinity__* (exact-name matching, and Trinity's own list_agents is prefixed).
  • Codex/Gemini blast radius — codex_runtime.py:707 reads guardrails["disallowed_tools"] directly, not merged_disallowed_tools, so the widened tuple adds no unmapped-name log noise on non-Claude runtimes.
  • Deferred-tool reachability — ToolSearch is kept while most of the denied family are deferred tools; the measured post-deny count (30 → 19 built-ins in the init array) is evidence the deny removes them from the set ToolSearch resolves against, not merely from the direct advertisement.
  • Mixed-fleet honesty — the family paragraph is a capability claim ("dies with this process"), so it stays true on images the deny hasn't reached; the deny-half/prompt-half release ordering is carried in both the PR body and agent-guardrails.md.
  • Docs — architecture.md, both feature flows, learnings.md and tests/registry.json all updated in-diff.

Verdict

Approve. I1 is the one I'd actually change before the base-image cut — it's a one-clause edit and the example is the part of the section a model is most likely to copy verbatim. I2/I3/I4 are notes for the record.

@vybe

vybe commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Re-triggering CI: no pull_request workflow ran on head 850cd6a (only journey-impact), so the four required contexts are absent and the merge is blocked. Closing and reopening to fire the reopened event — no code change.

@vybe vybe closed this Sep 2, 2026
@vybe vybe reopened this Sep 2, 2026

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

Validated via /validate-pr on top of dolho's /review: Fixes #2468, deny-list + prompt counterweight covered by 34 new tests (50 incl. test_2454 locally on the head), /cso --diff report in-diff with 0 findings, no new env reads, security scans clean. CI re-dispatched via close/reopen (no pull_request run existed on 850cd6a) — now 21/21 green incl. six-seed pytest + regression diff. Approving; merging.

@vybe
vybe merged commit c348cf9 into dev Sep 2, 2026
28 checks passed
vybe pushed a commit that referenced this pull request Sep 2, 2026
…conflicts in learnings.md + tests/registry.json with #2476)
vybe pushed a commit that referenced this pull request Sep 2, 2026
…ise#467) (#2483)

Fixes Abilityai/trinity-enterprise#467

/ws was SCOPE_ALL and unfiltered, so any authenticated user could read every tenant's agent names, execution ids and activity types. Both delivery paths (live fan-out and last-event-id replay) now filter on the client's accessible agents; identity resolution fails closed; admins short-circuit; /ws/events semantics unchanged.

Includes a merge of dev resolving both-append conflicts in docs/memory/learnings.md and tests/registry.json against #2476.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AQHbGS2GV78AmBFnZX78j6
@webmixgamer
webmixgamer deleted the feature/2468-headless-tool-audit branch September 2, 2026 11:11
vybe pushed a commit that referenced this pull request Sep 2, 2026
… (tag-only cut off dev) (#2502)

trinity-dev 406c390: a hyphenated tag (v0.9.5-rc1) now takes a tag-only
path off dev — no dev→main merge, no release PR, no Closes block, no
issue sweep — and Step 9 verifies publish-images.yml for both modes.
Companion to #2499, which withholds `latest` from a
pre-release tag; the playbook's new Step 2.12 blocker checks for it.

The bump is load-bearing rather than housekeeping: a `/release
v0.9.5-rc1` run from the pinned checkout would execute v1.5, which has
no RC mode and would treat the tag as a full cut — the dev→main merge
and the status-in-dev sweep that v1.6 exists to prevent.

Also carries the 13 intervening trinity-dev commits (debt-inbox entries
and the /sprint `--base dev` fix from #2476).

Refs #2281.


Claude-Session: https://claude.ai/code/session_012d5K93m76zw4Rn193FXvsJ

Co-authored-by: sim <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
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.

ScheduleWakeup is offered in one-shot headless runs — it schedules a wakeup that never fires and tells the model it WILL be re-invoked

3 participants