Skip to content

fix(agents): keep provisioned workspaces usable without templates - #120943

Merged
steipete merged 2 commits into
mainfrom
fix/workspace-template-comparison-nonfatal
Oct 24, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/workspace-template-comparison-nonfatal

Conversation

@steipete

@steipete steipete commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes agent replies failing with “Missing workspace template” when an existing workspace is used with an installation whose packaged templates are unavailable.

User Impact

Established workspaces can keep replying without their user-authored files being changed. Creating a missing bootstrap file still requires its template, and other template I/O failures still surface.

Why This Change Was Made

On the current main base (56d79851163cee1b83886d290f0c2b3f93036d83), src/agents/workspace.ts:762 loads all four templates before publication checks whether the destination files exist. Template comparisons also use the same strict loader.

Resolve template content lazily inside the existing bootstrap publication owner, after its existing-entry check. For comparisons only, treat the specific missing-template error as unavailable comparison data; preserve retired generated-file hashes and propagate other I/O errors. Custom-purpose consent checks and exclusive publication remain intact.

The replacement removes the previous catch-all fallback and status-only tests. The strict cached template reader is extracted to a small sibling loader; workspace lifecycle and comparison policy remain in their existing owner. Production delta: net +14; tests and test routing: +78; documentation: +3. The assertion-safety baseline decreases by one. Release-note context: provisioned agent workspaces continue to work when packaged templates are missing.

Evidence

  • Real prepareReplyWorkspace regression on the main base: fails with Missing workspace template: AGENTS.md; fresh-workspace strict failure and an actual EISDIR comparison-error control pass.
  • Fixed focused run: all 4 selected cases pass (the three missing-template cases plus the existing generated-attestation case). The initial broader owner run hit a 120-second timeout in that existing case under host load; its isolated reruns passed, including 15 seconds on the final extraction. Bootstrap publication: 4 cases passed; 3 existing Darwin cases hit helper-unavailable because their unchanged fixture forces FS_SAFE_NATIVE_MODE=off, while pinned fs-safe 0.26.11 requires native ACL inspection for private-directory creation. This limitation is recorded; no filesystem-policy or timeout changes are included. The separate Doctor check was stopped during prolonged startup so the mandatory loader extraction could be validated; it produced no test verdict.
  • Targeted type-aware lint, formatting, git diff --check, line-cap ratchet, and the final assertion-safety ratchet: clean.
  • Independent Codex reviews: final extraction and CI follow-up both scoped-clean, no actionable P0–P2 findings.
  • ClawSweeper Revision 13 reviews the final head: no findings and no before-merge items.
  • Initial exact-head CI run 40069873817 caught a moved unchecked type assertion in the extracted loader. The follow-up uses the existing typed filesystem-error helper and shrinks the now-lower workspace assertion baseline. Final exact-head CI is green for 382c8e44599352a815463544a71617150195437e: run 40073321371.

No live Gateway or model run was performed. This lane uses focused regression proof and PR CI for broad validation, as requested by the maintainer.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 9, 2026
@steipete
steipete marked this pull request as ready for review August 9, 2026 06:15
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 9, 2026
@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR defers bootstrap template reads until a file needs creation and tolerates missing templates during comparisons.

Example: A workspace contains user-authored AGENTS.md, SOUL.md, IDENTITY.md, and USER.md, but packaged templates are absent.

  • Before: Reply preparation fails with “Missing workspace template: AGENTS.md”.
  • After: Reply preparation succeeds without changing those files; fresh provisioning still requires templates.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with meaningful production-owner regression coverage and green exact-head CI; proof remains in process.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR records focused prepareReplyWorkspace regressions and exact-head CI, explicitly without a live Gateway/model run; ordinary contributor proof gating does not apply.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Agent replies fail despite existing usable workspace files when packaged templates are unavailable.
Reason: The maintainer-authored direction restores existing workspace use without adding configuration or substituting fallback instructions.

Merge readiness

✅ Ready for maintainer review

This PR remains useful and addresses both prior findings; no actionable introduced defect remains in the reviewed diff.

Priority: P1
Reviewed head: 382c8e44599352a815463544a71617150195437e

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped Gateway/model reply with packaged templates absent is recorded; supplied validation exercises the production workspace owner in process.
Agent review details

How this fits together

Reply preparation calls the workspace lifecycle owner, which checks persisted setup evidence and publishes missing bootstrap files before agent execution.

flowchart TD
  A[Reply preparation] --> B[Workspace lifecycle owner]
  B --> C[Existing setup and attestation state]
  B --> D[Bootstrap publication owner]
  D --> E[Existing entry preserved]
  D --> F[Strict template loader]
  F --> G[Missing file published]
Loading

Technical review

Best possible solution:

Keep lazy loading in the existing publication owner while preserving strict creation failures, typed comparison errors, and recorded generated-file evidence.

Do we have a high-confidence way to reproduce the issue?

Current-main source establishes the failure path, and the PR records a failing base regression through prepareReplyWorkspace; no target code was executed during this review.

Is this the best way to solve the issue?

This is a focused repair using existing owners, with strict provisioning and non-absence errors preserved and no unnecessary parallel implementation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 44c71714097f.

Provenance checked

  • Strict packaged-template loading changes intended behavior with a stated reason (319b4d0: Removed embedded fallback templates and made documentation templates authoritative.)
  • Exclusive bootstrap publication and custom-purpose consent keeps the original intent (a09bf68: Preserve approved custom-agent instructions through create-only publication and reject conflicting existing content.)
  • Previously generated content recognition keeps the original intent (a219fa5: Template edits must not turn untouched generated files into apparent user customization.)
  • Historical generated-file receipts keeps the original intent (7559fb2: Keep onboarding pending across release template changes until a real profile edit occurs.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned change and prior findings: The introduced diff replaces eager initialization reads with lazy publication callbacks and catches only MissingWorkspaceTemplateError during comparisons, addressing both findings in the previous review. (src/agents/workspace.ts:112, 382c8e445993)
  • Current main still needs the repair: Fetched main loads all four templates before publication checks existing destinations; strict comparison loading also remains. (src/agents/workspace.ts:762, 44c71714097f)
  • Latest release has the eager reads: The v2026.10.6 source reads AGENTS.md, SOUL.md, IDENTITY.md, and USER.md templates before checking whether publication is needed. (src/agents/workspace.ts:790, fe06181dc5ec)
  • Production-owner regression coverage: The new tests call prepareReplyWorkspace with real filesystem/state owners, verify unchanged user files, retain strict fresh-workspace failure, and exercise an actual EISDIR comparison error. (src/agents/workspace.missing-templates.test.ts:39, 382c8e445993)
  • Publication and existing-state compatibility: Existing-entry preservation, atomic exclusive creation, final mutation guards, custom-purpose conflict checks, historical generated hashes, and stored encodings remain intact; no data-model migration is introduced. (src/agents/workspace-bootstrap-publish.ts:24, 382c8e445993)
  • Exact-head CI: The linked CI run completed successfully for the reviewed head. The canceled older “PR context and evidence” run has later successful checks on that same head. (382c8e445993)

Likely related people:

  • Peter Steinberger: Raw commit a09bf68 adds src/agents/workspace-bootstrap-publish.ts:30 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a09bf683a9d5; files: src/agents/workspace-bootstrap-publish.ts)

PR surface

Source +14, Tests +78, Docs +3, Other 0. Total +95 across 7 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 3 65 51 +14
Tests 2 78 0 +78
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 7 147 52 +95

Review metrics

Metric Value Why it matters
Production versus regression coverage production net +14 lines; tests and test routing net +78 lines Growth supports lazy publication and typed absence handling; the strict loader is moved rather than duplicated, and the tests protect distinct failure boundaries.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove merge-risk: 🚨 session-state: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Missing packaged templates can prevent ordinary replies from otherwise usable workspaces in current main and the latest release.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (12 earlier review cycles; latest 8 shown)
  • reviewed August 25, 2026, 10:20 PM ET / August 26, 2026, 02:20 UTC sha unknown :: found issues before merge. :: [P1] Exercise the real provisioning path | [P2] Only suppress missing-template errors
  • reviewed 2026-09-03T00:17:47.931Z sha c7ba61a :: blocked before merge. :: [P1] Exercise the actual workspace provisioning path | [P2] Only downgrade the explicit missing-template condition
  • reviewed 2026-09-03T00:50:26.658Z sha c7ba61a :: blocked before merge. :: [P1] Defer strict template reads until provisioning needs them | [P2] Only downgrade the explicit missing-template condition
  • reviewed 2026-09-22T05:57:54.633Z sha c7ba61a :: needs changes before merge. :: [P1] Exercise and repair provisioning in the missing-template tests
  • reviewed September 27, 2026, 6:22 AM ET / 10:22 UTC (Revision 9) sha unknown :: blocked before merge. :: [P1] Exercise and fix the agent-turn initialization path | [P2] Propagate template read failures other than absence
  • reviewed September 27, 2026, 6:22 AM ET / 10:22 UTC (Revision 10) sha unknown :: blocked before merge. :: [P1] Exercise and fix the agent-turn initialization path | [P2] Propagate template read failures other than absence
  • reviewed 2026-09-27T10:22:16.294Z sha c7ba61a :: blocked before merge. :: [P1] Exercise and fix the agent-turn initialization path | [P2] Propagate template read failures other than absence
  • reviewed 2026-10-03T13:18:44.988Z sha c7ba61a :: blocked before merge. :: [P1] Exercise and repair the agent-turn initializer | [P2] Distinguish missing templates from template I/O failures

Reviewed October 24, 2026, 3:29 AM ET / 07:29 UTC (Revision 13).

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 10, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 20, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 3, 2026
@fuller-stack-dev fuller-stack-dev self-assigned this Sep 17, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 22, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Oct 3, 2026
Load templates only when bootstrap publication needs their contents. Treat only absent comparison templates as unavailable, preserving user files and non-absence I/O failures.
@steipete
steipete force-pushed the fix/workspace-template-comparison-nonfatal branch from c7ba61a to 2b541e7 Compare October 24, 2026 06:21
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 24, 2026
@steipete steipete changed the title fix(agents): agent turns fail when workspace templates are unavailable fix(agents): keep provisioned workspaces usable without templates Oct 24, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@steipete
steipete merged commit 1a76be1 into main Oct 24, 2026
174 of 175 checks passed
@steipete
steipete deleted the fix/workspace-template-comparison-nonfatal branch October 24, 2026 12:36
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
…enclaw#120943)

* fix(agents): keep provisioned workspaces usable without templates

Load templates only when bootstrap publication needs their contents. Treat only absent comparison templates as unavailable, preserving user files and non-absence I/O failures.

* fix(agents): keep workspace template errors typed
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
…20943)

* fix(agents): keep provisioned workspaces usable without templates

Load templates only when bootstrap publication needs their contents. Treat only absent comparison templates as unavailable, preserving user files and non-absence I/O failures.

* fix(agents): keep workspace template errors typed

Release adaptation: the stable workspace module does not export
fileDiffersFromTemplate, so the non-absence template error case is proven
through prepareReplyWorkspace instead.

(cherry picked from commit 1a76be1)
tideclaw-bot added a commit that referenced this pull request Nov 4, 2026
Adapt 28 audited units to the release-native ownership model.
Preserve AgentsAPI/cron policy and actor-owned projection recovery.

Source provenance and original contributor credit:
#176852 342fea1 — yinx65588-boop <[email protected]>
#180853 50f795a — Peter Steinberger <[email protected]>
#184041 e356196 — Peter Steinberger <[email protected]>
#184069 7739767 — Peter Steinberger <[email protected]>
#182666 9ff9d88 — Stefan Stüben <[email protected]>
#183884 112667f — Peter Steinberger <[email protected]>
#184021 05010ed — Peter Steinberger <[email protected]>
#183390 15a5706 — Masato Hoshino <[email protected]>
#183282 24d7dd3 — pstarkgit <[email protected]>
#164843 127f3c2 — PollyBot13 <[email protected]>
#172959 30f88d3 — main object unavailable; stable source inspected
#172959 eb2255b — johan-eilertsen <[email protected]>
#120943 1a76be1 — Peter Steinberger <[email protected]>
#178271 b3c8f8a — Wang Rui <[email protected]>
#178271 7bd6895 — RJ <[email protected]>
#177518 679980c — Masato Hoshino <[email protected]>
#182454 a538efe — Peter Steinberger <[email protected]>
#180042 bef193c — sunlit-deng <[email protected]>
#179347 2405bf4 — Peter Steinberger <[email protected]>
#179060 ccedbdc — Peter Steinberger <[email protected]>
#118011 9596527 — Peter Steinberger <[email protected]>
#182219 fade14f — Sukhdeep <[email protected]>
#181871 b1b5f00 — Peter Steinberger <[email protected]>
#178888 5125e3c — RoboClaw <[email protected]>
#180075 c9c2d16 — Wang Rui <[email protected]>
#181081 f223f77 — Jason O'Neal <[email protected]>
#180236 d11c239 — Dallin Romney <[email protected]>
#173921 af50fbd — Peter Steinberger <[email protected]>
#174868 7034ca4 — Peter Steinberger <[email protected]>
#172724 492c932 — Dallin Romney <[email protected]>

Proof: targeted owner/sibling tests, supported fresh two-pass review clean.
Known qualification gaps recorded in the release backport evidence.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants