Repository navigation
fix(templates): agent kept by a failed offline Add has no AGENTS.md - #199082
Conversation
When offline Add keeps the agent after a later step fails, the CLI now writes the default AGENTS.md, IDENTITY.md and USER.md into its workspace. The package BOOTSTRAP.md stays held, as openclaw#196392 intends, so a completed setup can still seed it.
|
🦞👀 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: ready, awaiting a maintainer decision. What this changesThis PR seeds permitted default instruction files after a failed offline Template Add retains an agent, while keeping package bootstrap deferred. Example: Offline Add creates agent kept, then its opening model request fails.
Review scores
ProductKind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Partial Merge readiness⏳ Ready, awaiting maintainer decision Keep this PR open: it addresses a current failure, resolves the earlier suppression-setting finding, and has no remaining concrete correctness findings; a Templates owner should decide whether to ship this partial recovery. Priority: P2 Decision needed
Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe offline Templates CLI consumes the shared installer's retained partial result and asks the workspace preparation owner to publish missing default instructions for later agent turns. flowchart TD
A[Offline Templates CLI] --> B[Shared Add installer]
B --> C[Retained partial result]
C --> D[Workspace preparation owner]
D --> E[Exclusive file publisher]
E --> F[Default instruction files]
F --> G[Later agent turn]
Technical reviewBest possible solution: Seed permitted defaults through existing workspace owners while preserving package-bootstrap custody and tracking complete recovery separately. Do we have a high-confidence way to reproduce the issue? Current-main source confirms durable deferral suppresses defaults after retained failure, and the contributor supplies matching CLI traces; this read-only review executed no target code. Is this the best way to solve the issue? The smallest complete fix for the stated defaults problem fits the existing preparation owner, preserves existing files and suppression settings, and avoids invalidating Gateway checkpoints; it intentionally does not complete the linked issue's package-bootstrap recovery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 088178a6559f. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +56, Tests +24, Docs +3. Total +83 across 4 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 14, 2026, 3:41 PM ET / 20:41 UTC (Revision 2). |
Offline Add now applies agents.defaults.skipBootstrap and skipOptionalBootstrapFiles when it gives a kept agent its default files, matching ordinary CLI preparation.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Baseline-Refresh: 169e7f1593874536dec62c384bd823591cab2012
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…penclaw#199082) * fix(templates): agent kept by a failed offline Add has no AGENTS.md When offline Add keeps the agent after a later step fails, the CLI now writes the default AGENTS.md, IDENTITY.md and USER.md into its workspace. The package BOOTSTRAP.md stays held, as openclaw#196392 intends, so a completed setup can still seed it. * fix(templates): kept agent's default files honor bootstrap suppression Offline Add now applies agents.defaults.skipBootstrap and skipOptionalBootstrapFiles when it gives a kept agent its default files, matching ordinary CLI preparation. * fix(templates): retain workspace evidence while seeding kept defaults --------- Co-authored-by: Patrick Erichsen <[email protected]>
Related: #198744 (this restores the default files; recovering the held package
BOOTSTRAP.mdafter a failed offline Add stays open there)What Problem This Solves
Fixes: when offline
openclaw templates addkeeps the new agent after a later step fails, the agent's workspace holds only the Template'sSOUL.md, and it stays that way after every turn. The failure message says "Continue setup in this agent", but the agent runs withoutAGENTS.md,IDENTITY.mdorUSER.md.User Impact
After a failed offline Add keeps the agent, its workspace also gets the default
AGENTS.md,IDENTITY.mdandUSER.md, the same files an agent gets on its first turn after a successful Add. The Template's own files are not replaced, and the operator'sagents.defaults.skipBootstrapandskipOptionalBootstrapFilesare honored exactly as ordinary CLI preparation applies them (src/agents/command/prepare.ts). The packageBOOTSTRAP.mdis still held back, because its first-run instructions can depend on the plugin, MCP server or automation whose setup failed. Successful Adds and Gateway Adds are unchanged.Why This Change Was Made
#196392 holds a Template's workspace bootstrap while Add runs: it sets
bootstrapDeferredandensureAgentWorkspacereturns early while it is set (src/agents/workspace.ts:592), so no turn can seed defaults or a genericBOOTSTRAP.mdahead of the package one. The deferral is cleared when the packageBOOTSTRAP.mdis seeded, which is the last Add step (src/templates/add-stateless.ts:674). When a later step fails and the agent is kept, nothing clears it. Gateway Add resumes that agent through Retry, which reaches the seed step. Offline Add has no resume, so the hold never ends and every turn skips the default files.Holding the package
BOOTSTRAP.mdis intentional, andconversation.workspace.test.tskeeps proving that a later seed still applies. So this change does not lift the hold. A newseedDeferredWorkspaceDefaultsinworkspace-preparation.ts, beside the deferral it respects, writes only the default instruction files that ordinary preparation would write under the currentagents.defaults(nothing withskipBootstrap, minus anyskipOptionalBootstrapFiles), with the existing exclusive-create publisher, and leavesBOOTSTRAP.mdand setup state untouched. It does nothing when the workspace is not held. The offline CLI, which owns offline custody, calls it after a partial result withagentRetained.It is not called from
applyTemplateAddPlanStatelessitself: Gateway-kept agents carry a configured checkpoint whoseworkspaceIdentitycovers every file in the workspace (src/templates/add-checkpoint.ts), so adding files there would make Retry report that the workspace changed.Accepted edge: if writing the default files itself fails, the CLI reports that error instead of the partial result. The agent is still kept and the next failure message names the cause.
Evidence
Current integrated candidate:
7b69a60f36cdd3661b29cfe3dfc7a52dd3aeb126The conflict repair preserves contributor ancestry and incorporates main at
355e5ae57e4eef2d39d1afa765613f2981d8d62cthrough the native baseline workflow. The retained-defaults caller now passes the workspace preparation owner's captured filesystem evidence to the existing exclusive publisher throughWorkspaceStateGuard. The complete product diff against that baseline remains four files, +83/-2; permitted defaults, suppression settings, existing-file preservation and packageBOOTSTRAP.mdcustody retain the original repair's behavior.conversation.workspace.test.ts,templates-cli.test.ts,templates-agent-conversation.test.tsandagents/workspace.test.ts(73 infrastructure + 24 CLI). The fresh-process custody regression, both suppression controls, existingSOUL.mdpreservation and subsequent package bootstrap seeding pass with the current filesystem owner.git diff --checkpassed.edab73ce2d97d08edb92aa723262608ade9b9b11; its original correctness findings were already resolved. This paragraph does not claim a new hosted review of the integrated head.SOUL.mdonly after a failed retained Add and later turn, versus permitted defaultAGENTS.md,IDENTITY.mdandUSER.mdwith this repair; package bootstrap stays held. Those captures are reused for unchanged CLI behavior. The new exact-candidate test/typecheck run specifically validates the filesystem-owner integration; no new model-backed CLI session was run for that mechanical adaptation.Hosted CI for this new candidate is pending publication; the earlier head's CI is not new-head evidence. The broader package-bootstrap recovery in #198744 remains open.
Offline CLI from
main(de20049) and from this branch, Gateway stopped, isolatedHOME,OPENCLAW_STATE_DIRandOPENCLAW_CONFIG_PATH, a local OpenAI-compatible stub for the model. The failing Add is a Template with a packageBOOTSTRAP.mdwhose opening model turn fails after the agent is committed (the stub is stopped during Add, then started again). This trigger does not depend on #198743.SOUL.md, and stillSOUL.mdafteropenclaw agent --local --agent kept --message hello.AGENTS.md IDENTITY.md SOUL.md USER.mdafter Add and after the turn. NoBOOTSTRAP.md.agents.defaults.skipBootstrap: truein the config: the same failing Add leaves only the TemplateSOUL.mdin the workspace, as ordinary preparation would.BOOTSTRAP.md SOUL.mdafter Add and all five files after one turn.Main (RED) and this branch (GREEN)
Tests: "retains package bootstrap custody through a fresh process after setup fails" in
src/templates/conversation.workspace.test.tsnow gives the kept agent its defaults the way the offline CLI does, runsensureAgentWorkspacein a fresh process, and expectsAGENTS.md IDENTITY.md SOUL.md USER.md, the TemplateSOUL.mdunchanged, nosetupCompletedAt, and thatseedTemplatePackageBootstrapstill seeds the packageBOOTSTRAP.md. With the helper doing nothing (main's behavior) it fails withexpected [ 'SOUL.md' ] to deeply equal [ 'AGENTS.md', 'IDENTITY.md', …(2) ]. Two more rows defer a workspace and seed it withskipOptionalBootstrapFiles: ["USER.md"]and withskipBootstrap: true; with the helper from e15f086 they fail withexpected [ 'AGENTS.md', 'IDENTITY.md', …(2) ] to deeply equal [ 'AGENTS.md', 'IDENTITY.md', …(1) ]and… to deeply equal [].node scripts/test-projects.mts src/templates/conversation.workspace.test.ts src/cli/templates-cli.test.ts src/cli/templates-agent-conversation.test.ts src/agents/workspace.test.ts --maxWorkers=1passes (91 tests).pnpm tsgo:core,pnpm tsgo:test:src, targeted oxlint, format check,pnpm check:import-cyclesandgit diff --checkpass.Merge risk: two-way door; reverting brings back the bare kept workspace with no state or config migration. Blast radius is offline
openclaw templates addruns that end partial with the agent kept and a held package bootstrap.Current-head CI qualification
CI run 43770661392, attempt 2 completed with one inherited updater-test failure. Its candidate-admission test still expects the old joined
Failing check node-runtimeoutput; upstream764761ee6450intentionally changed this path to a one-line refusal plus recovery steps and updated the analogous target-schema test, leaving this assertion behind. The refusal and no-side-effect checks pass before that formatting assertion.The actual tested merge
f182b244ade18deffa10e28c083da923dd9973d0has protected-main parent5b750071d1d31b2af9c8d2e58d0f65da010845dcand this exact PR head7b69a60f36cdd3661b29cfe3dfc7a52dd3aeb126. Its complete four-file delta leaves the failing updater, report, fixture, runner and dependency inputs unchanged. All other independent CI leaves passed or were normally skipped. The failed run remains failed; the 97 focused tests and type/lint/format proof above passed. Landing uses the repository's narrowly scoped inherited-CI qualification, preserving security and enforced review gates.