Repository navigation
model policy: check Claude's Agent tool; linked-machine and agent-option follow-ups (#802, #128) - #978
Conversation
…ine's pick leaves open Claude's own Agent tool (and Task in older Claude Code) is now checked against the model policy as each call is made. A PreToolUse hook is added to every Claude query through the fork's profile plan: enforce refuses a pick outside the rows or naming no model, advise lets it run with a note, and an inside pick gets its row's useFor. The alias is read as this machine's full id. A fork call must name an allowed model too, as the model guard reads it. Any error while checking refuses the call. #802: - Settings marks read the instance of the machine whose settings hold the picks, not another machine's instance with the same id. - A Claude pick sent to a linked machine that leaves the ultracode option out is read both ways, because that machine may turn ultracode on by default. The refusal says to name the option. - An option that picks an agent or a mode (OpenCode agent, Kiro mode, ACP session mode) is refused while the policy is on, even when the model list describes it. A test keeps the list in step with the model guard's. - A control that only a linked machine's agent has, and several effort ids for one driver, still fail closed. The refusals now say why and what to do. Fixes #802 Fixes #128 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
lens: state · reviewer: lens agent · read at: 9543d16 🤖 Generated with Claude Code |
|
lens: code · reviewer: lens agent (Claude Opus 5.5) · read at: 9543d16 Focus answers: an Agent or Task call (sub-agent type, fork, 🤖 Generated with Claude Code |
…t fails refuses - A row saved with a Claude alias (opus) now matches an Agent call naming it, as the MCP routes read it; a full-id row matches the alias that maps to it. The refusal says which alias and effort pass, or that none does. - Claude's Skill tool is checked: a skill with context: fork, or one naming model or effort, must name a model from the rows; a skill T3 cannot find or read is refused under enforce. - onFailure "block" on the hook while a policy is on, so a hook that times out refuses. - The agent-option lists are kept in step by the model guard's test, so app code reads no fork-owned file. - Tests pin one policy hook per query; docs name the fork's ignored effort and the alias mapping. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
lens: state r2 · reviewer: lens agent (Claude Opus 5.5) · read at: 1d5cee6 🤖 Generated with Claude Code |
|
lens: code r2 · reviewer: lens agent (Claude Opus 5.5) · read at: 1d5cee6 Focus answers: alias rows: the alias and the full id both match, in both modes; the refusal lists what passes, or says none does and what still runs. Skill: 🤖 Generated with Claude Code |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rser The Skill check parsed SKILL.md frontmatter with plain yaml.parse, which throws on an unquoted ": " in a value (description: Review the code: bugs and style). Claude Code and T3's skill list accept that, so an inline skill naming no model read as unreadable: refused under enforce, a note under advise. The check now uses parseSkillFrontmatter from ClaudeSkills.ts (one source for the repair step): exported there, with the whole frontmatter record on its parsed result (3 seam lines, announced in fork-seams.json first). Docs: with a policy on, in advise too, Claude Code 2.1.295 or newer is required; an older one refuses every new query. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
List only: announces the 3 upstream lines #978 adds to apps/server/src/provider/Drivers/ClaudeSkills.ts (export parseSkillFrontmatter and keep the whole frontmatter record on its parsed result), in a new entry with "added": [] and its lines under "announced". Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…ines added The announce (#990) is on main, so the three ClaudeSkills.ts lines move from "announced" to "added". The model policy's PreToolUse hook now goes into the plan before main's lazy options wrapper, so adding it reads no options early. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main's test of a plan fixed only as its process opens expected empty options; on this branch every plan carries the model policy's Agent and Skill hook, so the test checks that hook is the only option. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ch11 # Conflicts: # FORK_CHANGES.md
|
not a lens: narrow check after round 2 Verdict: SAFE TO MERGE (head
Tests: I ran claudeAgentModelPolicy (11), ClaudeSkills (26), claudeMcpProfile (55) and claudeMcpProfile.adapter (12) one at a time on the head. All passed. 🤖 Generated with Claude Code |
Fixes #802. Part of #128: forked skills are checked or refused here; what is left (skills T3 cannot read, a same-name skill in a place T3 does not read, the instance's own alias mapping) is #987.
What and why
#128: Claude's own Agent tool now follows the model policy. The owner decided on 2026-11-15 that while the policy is on, every call that starts a built-in sub-agent must name an allowed model. Until now T3 checked only its MCP routes (
delegate_task,create_threads,t3_thread_launch,t3_thread_configure). Claude's Agent tool, or Task in older Claude Code, never reached the server.apps/server/src/fork/claudeAgentModelPolicy.ts(new) is a PreToolUse hook forAgentandTask. It reads the call'smodelandeffortand checks them with the samemakePickCheckthe MCP routes use, on the new route"Agent".enforcerefuses a pick outside the rows, a call that names no model, and a call withinherit. The refusal shows the rows and how to fix the call.adviselets the call run and adds a note.useFor.off, or on a host without settings, nothing is checked.opus) is read as the full id from this machine's Claude model list, which is the same mapping T3 uses for the sub-agent it shows. A row matches when it names the alias (asdelegate_taskreads a row saved asopus) or that full id. The refusal says which alias and effort pass, or that none does. A name the list does not map stays as given, so it matches no row.context: fork, or one that namesmodeloreffort, must name a model from the rows in its frontmatter. A skill that runs inline and names neither is not checked. A skill T3 cannot find or read is refused underenforceand gets a note underadvise.onFailure: "block", so a hook that times out refuses. With the policy off it is left out, so a Claude Code older than 2.1.295 still opens.forkcall is read like any other call: underenforceit must name an allowed model, as the owner decided and as the model guard (fork-kit/model-guard) already reads it. Claude itself runs a fork on the session's own model and ignores the model the call names.agent()calls stay with the model guard, because the script is code and this hook does not read it.makeClaudeMcpProfiles(claudeMcpProfile.ts) puts the matcher first inoptions.hooks.PreToolUseof every plan, including no profile, t3-only and barebuiltinTools: none. The upstream adapter already spreadsmcpProfileOptionsand its hooks into each query, so no upstream file changes.#802, point 1: Settings marks across machines (done).
personModelPickMarksnow takes the machine whose settings hold the picks. It reads only that machine's instance with the pick's instance id. A provider that has no machine id still counts.ModelPolicySettings.tsxpasses the scope'starget.environmentId.#802, point 2: what the sending machine cannot know.
pickOfRemote) now setsultracodeDefaultUnknown. AclaudeAgentrow then reads a pick that leavesultracodeout both ways, with ultracode and without, because the receiver's model list may turn ultracode on by default. If the row does not allow both readings, the pick is refused, and the hint says:Name the option ultracode in target.options: { "id": "ultracode", "value": false } runs the effort named, true runs ultracode. A pick for this machine still reads the catalog's real default. Rows of other drivers (codex) are not affected.adviseor off.#802, point 3: one driver, several effort ids (kept fail closed, explained). The pick must still name every id. The issue allows this ("Fails closed; say so in the refusal or the docs, or check per instance").
#802, point 4: options that pick an agent or a mode (done). While the policy is on, the server now refuses OpenCode
agent, Kiromodeand the ACP session mode_t3/session-mode, even when the model list describes them.DRIVER_MODEL_OPTION_IDSplus ACP'sACP_SESSION_MODE_OPTION_ID. The model guard's test (fork-kit/model-guard/tests/guard.test.py) readsmodelPolicy.ts, so the lists cannot drift apart; app code reads no fork-owned file. A server test keeps the session mode equal to ACP's own constant.Umbrella: #876. #731 and #899 (machine install / enforce) are not touched.
Tests: each fix fails without it
Each fix was undone on its own, its tests were run, and then the fix was restored:
modelPolicySettings.logic.ts)reads the instance of the machine whose settings hold the picks, not another machine's with the same id (#802)a pick for a linked machine that leaves ultracode out reads both ways on a Claude rowpickOfRemotesetsultracodeDefaultUnknown(server)sent to a linked machine: the model's ultracode default counts both waysrefuses it, on a known driver and on a pick for a linked machine; leaving it out is insideseveral effort ids for one driver: the refusal names each and why (fail closed)refuses an option that picks an agent or a mode while the policy is on, even when describedmodelPolicyCheck,delegateOwnOptions,launchMcpProfile(all routes, here and sent)every query carries the model policy's check of Claude's Agent tool (#128)claudeAgentModelPolicy.test.tsis new: enforce, advise, off, no settings, alias, fork, Task, and failing closedOlder tests changed because of the fixes:
claudeAgentrow now nameultracode.Run locally:
packages/contractsmodelPolicy: 31 passed.apps/server/src/fork: 58 files, 1220 tests passed.apps/websettings/fork unit tests: 69 passed.effect-tsgotypecheck of contracts, server and web: clean.vp lint: no errors.vp fmt --check: clean.fork-seam-check.cjs, as CI runs it): passes against main. fork-seams: announce the ClaudeSkills.ts lines #978 adds #990 (announce) is merged, so this PR moves the 3ClaudeSkills.tslines fromannouncedtoaddedin.github/fork-seams.json. Schema, upstream-files and seam-check tests pass.Round 1 review (code and state lenses)
opus) blocks every Agent callnamedAs), so a row naming the alias or the full id matches; the refusal lists the Agent aliases and efforts that pass, or says none doesa pick read as a full id from the name it gave (namedAs) matches a row naming either; servera row saved with the alias matches the alias the call names, in both modes,rows no alias reaches: ...discoverClaudeSkillsfinds it); unfound or unreadable is refused under enforce (fail closed). Left, in #987: skills T3 does not read (bundled, MCP, commands, add-dir), and a same-name skill in a place T3 does not readenforce: checks the frontmatter of a skill that runs forked or names a model,fails closed: a skill T3 cannot find or read is refused under enforcefork-owned-reads.test.pypasses locally and fails on the old testguard.test.pytest_agent_picking_options_are_the_servers_model_policy_onesonFailure: "block"a hook that fails or times out refuses while a policy is on (onFailure block); adapter testevery query carries the model policy's check of Claude's Agent tool once (#128)delegate_taskis refusedcheckLaunch). Skipping the check on a repeat would send an unchecked pick to a receiver in advise or offState: runs again (the hook is added once per query, two turns tested; the same call gets the same answer), stops half-way (a throw, a dying settings read or an unreadable skill refuses; a timeout refuses under
onFailure: "block"), old state (alias rows saved before now match the alias).Round 2 review (state: not safe; code: safe)
:in a value (description: Review the code: bugs and style), reads as unreadable: refused under enforce, a note under adviseparseSkillFrontmatterinClaudeSkills.ts, with its:repair), one source. It is exported there and its parsed result carries the whole record: 3 upstream seam lines, announced first in #990 (list only). Frontmatter still broken after the repair is refused under enforce, as beforeenforce: checks the frontmatter of a skill that runs forked or names a model(inline-colon: allowed under enforce, no note under advise;fork-colon: its model is read and refused);fails closed: a skill T3 cannot find or read is refused under enforce(colon-broken)docs/fork/README.md, model policy): 2.1.295 or newer is required while a policy is on, inadvisetoo. A version warning is in #987 (point 4)$namemention in a turn's text becomes a native/namecommand: no Skill call, the hook never runsUserPromptExpansionhook)Round-2 minors in one comment: #987 (comment)
State question
enforce, as before.off, or a host without settings, checks nothing.enforce, a Claude pick sent to a linked machine withoutultracodeis now refused (the hint says to name it). An OpenCodeagentor ACP session-mode option is also refused, and so is an Agent call without a model.advise, each of these runs with a note.General vs project
All of this is general. The models, efforts and modes come from the
modelPolicysetting (each machine's own config) and from each machine's model lists. Nothing names a project, repo, machine or person. The agent-option ids come from the drivers (OpenCode, Kiro, ACP) and are the same list the model guard already uses. The Claude tool names (Agent,Task) and theforktype are Claude Code's own.🤖 Generated with Claude Code