Repository navigation
Conversation
Agents enrolled by the earlier installed-Template lifecycle (claws add or claws migrate) refuse every turn after any edit to their config, such as setting tools.exec.mode=full, and the error told operators to repair the state database. Add is now one-way, so there was no supported way to keep the change. Add `openclaw templates release <agent-id>`. It needs exclusive offline state ownership, shows the agent's tool settings and whether they still match the recorded consent, asks for confirmation (--yes in scripts), and removes that agent's Template ownership rows in one transaction after re-reading the install record. The agent, workspace, sessions, cron jobs, MCP servers, and plugins stay as ordinary resources. A config mismatch now gets its own error naming the release command. Template profiles still cannot set tools.exec or tools.message.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: stale review; fresh review needed. Summary Next step Review history (3 earlier review cycles) |
The release delete only checked database admission, so a signal or lost state lock after the operator confirmed still let it commit. Recheck the offline owner's custody in the write admission at the transaction and commit stages, and cover custody ending after confirmation.
…ols-consent # Conflicts: # docs/cli/templates.md
|
The Templates lifecycle is now one-way Add (#171623), and #175577 kept legacy consent fail-closed. That leaves agents enrolled by the earlier #196338 proposes an explicit, offline, operator-confirmed release. It removes only that agent's Template ownership records, keeps the agent and its resources, and keeps the consent check itself unchanged. Template manifests still cannot grant Is this transition acceptable to the Templates owners? If not, which recovery would you prefer? |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…ols-consent # Conflicts: # docs/cli/templates.md # src/templates/openclaw-profile.test.ts
* fix(templates): release earlier Template-managed agents Let operators release an earlier Template-managed agent after an intentional configuration edit while retaining its agent, workspace, conversation and integrations. Require explicit confirmation and exclusive offline custody, recheck that custody at the write, and remove only its Template ownership records. Point changed-consent errors at the supported recovery command. Maintainer-owned replacement of #196338 from source 1ab986c, preserving Anmol's implementation and subsequent main documentation and test changes. Co-authored-by: Anmol Bhardwaj <[email protected]> * docs(templates): align release guidance with preferred models --------- Co-authored-by: Anmol Bhardwaj <[email protected]>
|
Landed and verified in credited maintainer replacement #200303 (merge Closing this original as superseded after replacement merge and verification. The replacement records its focused regression/upgrade proof, limitations and the specifically qualified unrelated Windows updater CI failure. Exact merged-commit security, documentation publishing and workflow checks passed. |
) * fix(templates): release earlier Template-managed agents Let operators release an earlier Template-managed agent after an intentional configuration edit while retaining its agent, workspace, conversation and integrations. Require explicit confirmation and exclusive offline custody, recheck that custody at the write, and remove only its Template ownership records. Point changed-consent errors at the supported recovery command. Maintainer-owned replacement of openclaw#196338 from source 1ab986c, preserving Anmol's implementation and subsequent main documentation and test changes. Co-authored-by: Anmol Bhardwaj <[email protected]> * docs(templates): align release guidance with preferred models --------- Co-authored-by: Anmol Bhardwaj <[email protected]>
Closes #190694
What Problem This Solves
Fixes: an agent enrolled by the earlier
claws add/claws migratelifecycle refuses every turn when its config is changed, for example withopenclaw config set agents.entries.<id>.tools.exec '{"mode":"full"}'. The error (configuration does not match its consent provenance) tells the operator to repair the state database, and there is no supported way to keep the change. This still reproduces on the latest stable, v2026.11.2.User Impact
With the Gateway stopped, an operator can review and release the agent:
The agent then runs with the operator's settings and keeps its workspace, sessions, cron jobs, MCP servers, and plugins. The runtime error now names this command. Agents added on current main are unaffected; they have no consent record.
This changes how historical consent provenance can end, so it needs an owner decision and a security review. No CODEOWNERS rule or
security-review-policy.ymlclass coverssrc/templates/**, so it needs to be routed toopenclaw-secopsby hand.Why This Change Was Made
Add has created ordinary agents since #171623, and #175577 deliberately kept the legacy consent check fail-closed. That check is unchanged here. The missing piece was an explicit operator action that moves a legacy agent onto the ordinary-agent model, as ClawSweeper recommended on the issue.
templates releaseuses the same exclusive offline ownership astemplates add(runWithLocalStateOwnerwithonForeignOwner: "refuse"). No Gateway method or protocol change.templateRelease.apply). Its admission rechecks offline custody (the owner'sassertCurrent: the state lock is still held and no exit signal has arrived) at both the transaction and commit stages. Inside the transaction it re-reads the install record and deletes only if the schema version and digest still match what the operator reviewed.template_installs,template_workspace_files,template_package_refs,template_mcp_server_refs, andtemplate_cron_refs. On main, the only runtime reader of those child tables is Add's package rollback guard, which also requires its own install stamp. So jobs, servers, and plugins are left alone (shown below).matchTemplateConsent, shared by the runtime and the command. A mismatch is now its own result with an actionable message, instead of a state error.tools.execandtools.message, so a Template cannot grant full exec or cross-provider messaging at Add. The docs say to set them after Add.Root cause
src/templates/tool-policy-runtime.tscompared the live agent config digest with the one in the legacy install record, and turned any mismatch into a state error. The digest covers the whole agent entry exceptmodelandsubagents, so any edit trips it; on main, renaming the agent (name) also blocks it. Undoing the edit was the only recovery.Evidence
All runs used an isolated
HOME,OPENCLAW_STATE_DIR, and Gateway port, withscripts/e2e/mock-openai-server.mjsas the model. API keys are mock values.Upgrade path: 2026.10.9 → latest stable 2026.11.2 → this branch
Agent
opswas created by 2026.10.9claws addfrom a package declaring a cron job and an MCP server. Each version randoctor --fixon the previous version's state.On 2026.11.2 (b556fdf):
"text": "OPENCLAW_E2E_OK".config set agents.entries.ops.tools.allow '["read","exec"]'andconfig set agents.entries.ops.tools.exec '{"mode":"full"}', the turn fails:Cannot verify the installed tool authority for Claw-managed agent "ops". Repair the OpenClaw state database before running it. | Claw agent configuration does not match its consent provenance.templates releasegivesOpenClaw does not know the command "templates".On this branch, same state:
doctor --fixexits 0. Before release, the install, cron, and MCP ref rows foropsare each 1.templates release ops --yesprintsIts settings changed after the Template consent was recorded.,Tool settings it keeps: {"profile":"full","allow":["read","exec"],"exec":{"mode":"full"}}, andReleased ops., exit 0. All three ref counts are now 0.7211420c-…|ops|Daily summary|1incron_jobsis unchanged, andmcp liststill showsstatuspage.config get agents.entries.ops.toolsstill hasexec.mode: "full".OPENCLAW_E2E_DRAFTPROOFmakes the model callexecwithsleep 2 && echo openclaw-draft-proof, a compound command. The turn completes, and the captured model request contains the tool outputopenclaw-draft-proof.Authority boundary (
worker, enrolled by 2026.10.9claws migrate)Cannot admit templates.release ... requires exclusive offline state ownership. No local mutation was attempted., exit 1.--yes, non-TTY stdin:Release not confirmed., exit 1, install row still present.--yesreleases it. After a restart the turn completes, and a second release printsNothing to release.promise resolved "undefined" instead of rejecting): the delete committed after the signal. This revision adds the custody recheck.Edge case
When
agents.defaults.modelsis set, adopted consent cannot be recomputed. The agent is blocked with the state-database message on both main and this branch (the #193383 symptom). Release printsIts settings cannot be compared with the Template consent: ..., releases, and the next turn completes.Tests and gates
src/cli/templates-cli.release.test.ts(3 tests) uses a real SQLite install record and real state-lock custody: release unblocks an edited agent after restart; an unconfirmed release keeps consent; custody lost after confirmation keeps consent.src/templates/tool-policy-runtime.preparation.test.tswas updated for the release guidance. With the production files reverted to the base it fails on the old message.src/templates/schema.test.tspins theCLAW.mdmanifest rejection oftools.execandtools.message(moved there after feat: configure Templates in one CLAW.md manifest #196322 folded profiles intoCLAW.md). It passes on main too; the schema is intentionally unchanged.pnpm teston the touched suites and consumers (templates-cli,templates-cli.state-owner,openclaw-state-worker-registry,tool-policy-runtime,io.runtime-models,tool-policy-pipeline,agent-tools.prefix-stability) passes.pnpm tsgo:core;run-oxlintandrun-format --checkon the touched files;git diff --check;check:test-lines-ratchet.Gaps
assertCurrentas the signal case.cron listdoes not show theopsjob after a Gateway restart on 2026.10.9 itself, before any upgrade, although the row stays incron_jobs. Release does not touchcron_jobs. That listing behavior predates this change.Merge risk: two-way door. Reverting removes the command and restores the old message. Released agents stay ordinary, since their records are deleted, and need no migration. Blast radius is agents that still have a legacy Template install record.