Skip to content

fix(templates): attach chat while dependency setup settles - #198637

Merged
Patrick-Erichsen merged 62 commits into
mainfrom
template-add-responsive-delivery-restacked
Nov 16, 2026
Merged

Patrick-Erichsen merged 62 commits into
mainfrom
template-add-responsive-delivery-restacked

Conversation

@Patrick-Erichsen

@Patrick-Erichsen Patrick-Erichsen commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

What problem this solves

Template Add waits for every dependency before the agent can speak. Slow setup stalls the opening; the composer handoff can lose queued input. A failed opening also left Retry unable to dispatch after a same-scope Gateway reconnect.

What changes

Finalize the prepared agent/session before dependency setup, attach chat and start its opening while dependencies settle. The existing continuation serializes checkpoints and reports dependency results after the opening. Retry preserves the same agent, files and settled work.

The retained composer belongs to the account/Gateway presentation scope, not an obsolete transport object. An explicit Retry captures the current connected transport; in-flight result fences and cross-scope guards remain. Existing owners retain drafts, attachments and queued input. No new owner or automatic retry is added.

Source acquisition stays verified. Timing diagnostics use debug severity. Referenced ClawHub plugins remain recommendations, never automatically installed/enabled. Denies, consent and installation policy are unchanged.

Stacked above setup #198603, above creation. The foundation #198065 has merged; this PR has not.

Evidence

Head d387ddc9146de4b5e547f06b5f14dfe3865debe9, parent 577e12a6b457945be951b6e97a753b9c2cfebaef. Screenshot descendants replay patch-identically, ending at 7ef2cc972b6ea4bdf3edbf7eaaa36b1d96bd26da. Since the tested reconnect snapshot, only the custody-test consolidation and removal of its unused allocation changed; production source is unchanged.

Test-budget review repair

The reviewed fc9c6a8f0e2642828729ca06dcb63577d2809c6f fails the ratchet at +440 net test lines against 400+21, exceeding the limit by19. This head shares the two existing live-custody scenarios in a table without dropping distinct contracts. Both canonical/noncanonical routes remain; additional custody assertions now run for both. The reconnect cases are untouched and the suite still has11 cases.

After: ratchet passes at +394 against400, allocation credit0. The now-unused per-change allocation was deleted, not increased. Exact responsive-head suite: 11/11, 2.88s (wrapper3.97s); one-file type-aware lint:5.46s; formatting and diff checks pass. This is a test-only refactor, so retained runtime/visual proof remains unchanged-input evidence rather than a new recording.

Inspected paired real-Gateway recovery proof, including before/after images:

  • Deliberately fail the opening, retain the chat, restore the provider, cold-restart only the isolated Gateway, then click Retry. The old transport-bound run stays stuck; the repaired run returns partial → complete for the same agent and session with resume:true.
  • Exactly one queued send includes its attachment. Neither the unsent draft nor its separate attachment appears in any send; both remain in the composer. The real provider replies to the queued message. Browser page errors: zero.
  • The owning reconnect regression fails on the prior binding and passes with the repair. The prior reconnect snapshot passed all30 focused Add/admission cases, targeted formatting/type-aware lint/UI types and canonical full build. Absolute advisory performance warnings remain, not a fresh strict paired-performance pass.
  • Real combined-stack Add, card-only recommendation and reviewed theme install are covered by the separate inspected Add/install evidence. That run uses earlier combined4a4f, not standalone foundation or this exact head.

The latest-stable ordinary-session rehearsal starts with official2026.11.3, upgrades to the earlier combined production build, then cold-restarts: session identity/label/root, workspace hashes and absence of Template-only fields survive; the candidate route/composer is inspected. That fixture does not prove an ordinary live-provider turn or new Template receipt semantics. The separate recovery run above proves the cold same-agent Retry path. Neither run is a delayed-dependency demo or a broad plugin-capability consent-dialog demo.

Retained validation and limits

Unchanged-input evidence remains prior-head evidence: 167 owner tests/nine files plus14 UI tests; prompt7/7; logging33/33; repaired real-owner identity/questions7/7; combined card/lazy/identity/questions34/34 and UI-chat type graph. The prior strict paired performance comparison reduces chat JS187B and New Session364B, with startup/CSS unchanged and no budget increase. It is not rerun for the current head.

The prior bounded changed-file run passed13 core type graphs, UI types, format/i18n/controller/ratchet guards, then reached its180s deadline. Separate coercion guard and final two-file type-aware lint passed. The remaining deadcode scan reports the same unchanged script/runtime exports previously reproduced on basee68; its full-tree scan reaches a separate90s bound. These wrappers are not claimed green. No allowance, assertion, scanner or timeout was weakened.

Prior UI/model-picker/native-recovery failures have bounded exact-signature baseline evidence, not current-head green CI or a landing waiver. Earlier Package Acceptance passed its selected survivor lanes for candidate1645; skipped lanes and missing Template-specific evidence stay qualified. No completed Add, install or package run was redispatched.

Hosted ClawSweeper remains the selected reviewer. Current-head review/CI and native ordered landing remain open. Delayed-dependency live proof and any broader consent continuation remain explicitly unproven. Only the task-owned isolated Gateway was restarted and stopped; production and protected services were unchanged. No deployment or release.

The card payload reader required official: true, so a Gateway-authored card
for a community plugin was dropped before it reached the chat. Plugin cards
now carry the registry's official flag; skill cards stay official-only.

The loading placeholder shows the official badge only for official cards.
The loaded card already rechecks the Gateway's catalog answer, shows no badge
for a community plugin, and offers View details instead of Install.
clawhub now takes either query (search, unchanged) or plugin, the exact
ClawHub package name. The exact form looks up that one package, never falls
back to search, and shows its existing card. A name ClawHub does not know,
or that is not a plugin, returns an explanation and shows no card.

Search still returns official plugins and skills only. An exactly named
community plugin is shown with the registry's own official flag.
The release detail already validates the Template's agent id from the
ClawHub manifest summary. Return it so a client can name the agent it
wants before Add, without a plan.
A request with mode "chat" names the agent id it wants and carries no plan
digest. The Gateway admits the agent and chat under an unused id, fetches the
Template, writes its workspace, then installs declared skills, bundled plugins
and MCP servers one at a time. A dependency that cannot be set up is collected
instead of stopping creation, and plugins referenced on ClawHub and automations
are left to the agent's conversation. Failing to fetch the Template or write
its workspace removes the agent and chat this request created.

The agent's first turn starts after creation and receives a setup report
through buildTemplateOpeningMessage, which still returns the existing opening.
The plan-based request used by the CLI is unchanged.
Chat-based Add copies the Template's CLAW.md unchanged to the workspace root
as an ordinary file, bound into the same retry checkpoint as the other
workspace files. A Template whose own workspace files claim that path keeps its
file and the setup report says so.

The saved tool allowlist gains automations, plugins and message when the
Template's allowlist omits them. A Template without an allowlist inherits the
operator's policy, and a tool the Template denies stays denied.
Drive templates.add.apply in chat mode against a Template fixture shaped like
Travel Copilot, with real admission, workspace, bundled skill and plugin, MCP
and rollback owners. A declared plugin that is installed but disabled does not
block, a missing skill keeps the agent and is reported, an unfetchable Template
or failed workspace write leaves no agent, chat or workspace, and a taken id
yields the next unused one.
Add no longer requests templates.add.plan. It sends one chat-mode
templates.add.apply with the release's package name, exact version and an
agent id derived from the Template's own id, then opens the pending chat as
before. The review step for plugin capability grants and skill warnings is
gone from the Add path; ClawHub's audit of a flagged release still asks first.

A card Add reads the release detail once, because only the detail names the
Template's agent. When the Gateway answers a first Add with an error it kept
nothing, so the user returns to the catalog with the error on that card.
The Gateway is moving to create a Template agent deterministically and
leave the remaining setup to the agent's own first turn. This adds the
hidden prompt for that turn. It is not used yet.

The prompt fixes the order of the setup conversation: greeting, paused
automations from CLAW.md, added MCP servers, ClawHub plugin state and
install cards, creation failures, then the author's BOOTSTRAP.md
opening. Automations carry the same declaration key, schedule, session
target and delivery as the Gateway installer creates today, so a second
run adds no duplicates.

CLAW.md and the report are author-influenced, so the prompt treats them
as data. Report text reaches the model only as bounded JSON, and two
rules hold whatever a workspace file says: automations stay paused, and
only the user installs or enables a plugin.
Carry main's authored MCP declaration read into the timed Template Add call.
Base automatically changed from template-setup-delivery-integrated to main November 16, 2026 03:35
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Nov 16, 2026
The squash commit's tree equals the merge of its parent with the setup head
this branch already contains, so this branch's tree is unchanged.
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Security-sensitive guard cleared

Current revision: 0ab4ebd53158c50fdaa01c49bbbd6b5e107727d2

This PR no longer changes files in the maintainer security-review tier.

Separate CODEOWNERS requirements still apply to security policy and enforcement files.

@openclaw-barnacle openclaw-barnacle Bot removed the docs Improvements or additions to documentation label Nov 16, 2026
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 16, 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. and removed 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 Nov 16, 2026
@Patrick-Erichsen
Patrick-Erichsen merged commit 63f9306 into main Nov 16, 2026
151 of 155 checks passed
@Patrick-Erichsen
Patrick-Erichsen deleted the template-add-responsive-delivery-restacked branch November 16, 2026 04:22
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

Patrick-Erichsen added a commit that referenced this pull request Nov 16, 2026
The squash commit's tree equals the merge of its parent with the responsive
head this branch already contains, so this branch's tree is unchanged.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 17, 2026
…198637)

* feat(clawhub): let chat plugin cards represent community plugins

The card payload reader required official: true, so a Gateway-authored card
for a community plugin was dropped before it reached the chat. Plugin cards
now carry the registry's official flag; skill cards stay official-only.

The loading placeholder shows the official badge only for official cards.
The loaded card already rechecks the Gateway's catalog answer, shows no badge
for a community plugin, and offers View details instead of Install.

* feat(message): show one exact ClawHub plugin card by package name

clawhub now takes either query (search, unchanged) or plugin, the exact
ClawHub package name. The exact form looks up that one package, never falls
back to search, and shows its existing card. A name ClawHub does not know,
or that is not a plugin, returns an explanation and shows no card.

Search still returns official plugins and skills only. An exactly named
community plugin is shown with the registry's own official flag.

* docs(control-ui): document exact ClawHub plugin cards

* fix(chat): render source reply cards before run adoption

* test(chat): classify producer display regression as Node integration

* fix(message): send ClawHub cards without generated captions

* perf(chat): consolidate source reply admission and card decoding

* test(chat): document independent card delivery proof boundaries

* refactor(chat): use native named-export lazy card loading

* refactor(outbound): keep attachment normalization in payload owner

* test(chat): attach profile isolation reason to the mock

* feat(templates): name the Template's agent in catalog detail

The release detail already validates the Template's agent id from the
ClawHub manifest summary. Return it so a client can name the agent it
wants before Add, without a plan.

* feat(templates): add a plan-free chat mode to templates.add.apply

A request with mode "chat" names the agent id it wants and carries no plan
digest. The Gateway admits the agent and chat under an unused id, fetches the
Template, writes its workspace, then installs declared skills, bundled plugins
and MCP servers one at a time. A dependency that cannot be set up is collected
instead of stopping creation, and plugins referenced on ClawHub and automations
are left to the agent's conversation. Failing to fetch the Template or write
its workspace removes the agent and chat this request created.

The agent's first turn starts after creation and receives a setup report
through buildTemplateOpeningMessage, which still returns the existing opening.
The plan-based request used by the CLI is unchanged.

* feat(templates): copy CLAW.md and allow setup tools in chat-based Add

Chat-based Add copies the Template's CLAW.md unchanged to the workspace root
as an ordinary file, bound into the same retry checkpoint as the other
workspace files. A Template whose own workspace files claim that path keeps its
file and the setup report says so.

The saved tool allowlist gains automations, plugins and message when the
Template's allowlist omits them. A Template without an allowlist inherits the
operator's policy, and a tool the Template denies stays denied.

* test(templates): cover chat-based Add at the Gateway request seam

Drive templates.add.apply in chat mode against a Template fixture shaped like
Travel Copilot, with real admission, workspace, bundled skill and plugin, MCP
and rollback owners. A declared plugin that is installed but disabled does not
block, a missing skill keeps the agent and is reported, an unfetchable Template
or failed workspace write leaves no agent, chat or workspace, and a taken id
yields the next unused one.

* feat(ui): add Templates from the Control UI without a plan

Add no longer requests templates.add.plan. It sends one chat-mode
templates.add.apply with the release's package name, exact version and an
agent id derived from the Template's own id, then opens the pending chat as
before. The review step for plugin capability grants and skill warnings is
gone from the Add path; ClawHub's audit of a flagged release still asks first.

A card Add reads the release detail once, because only the detail names the
Template's agent. When the Gateway answers a first Add with an error it kept
nothing, so the user returns to the catalog with the error on that card.

* docs(templates): describe plan-free Add from the Control UI

* fix(templates): retain effective setup tool grants in chat Add

* fix(ui): open Template chat before resolving release details

* fix(templates): reserve original manifest in chat Add

* fix(templates): extract Gateway Add result leaf contract

* perf(templates): keep trust decoder outside shared UI boot

* fix(templates): report incomplete chat Add setup truthfully

* test(templates): preserve reviewed checkpoint across chat retry refusal

* fix(pr): include the ClawHub trust reader in wrapper extraction

* perf(templates): decode trust errors without connection adapter

* fix(templates): explain reserved manifest recovery after rollback

* test(templates): reconcile creation regression allocation

* feat(templates): add the setup prompt for a new Template agent

The Gateway is moving to create a Template agent deterministically and
leave the remaining setup to the agent's own first turn. This adds the
hidden prompt for that turn. It is not used yet.

The prompt fixes the order of the setup conversation: greeting, paused
automations from CLAW.md, added MCP servers, ClawHub plugin state and
install cards, creation failures, then the author's BOOTSTRAP.md
opening. Automations carry the same declaration key, schedule, session
target and delivery as the Gateway installer creates today, so a second
run adds no duplicates.

CLAW.md and the report are author-influenced, so the prompt treats them
as data. Report text reaches the model only as bounded JSON, and two
rules hold whatever a workspace file says: automations stay paused, and
only the user installs or enables a plugin.

* feat(gateway): run a Template setup prompt with the agent's tools

The Template opening turn passed an empty runtime tool allowlist, which
removes every tool, so the agent could not finish its own setup.

startAgentOnboardingConversation now accepts the setup prompt for a
Template agent. With one, the turn sends that prompt and passes no
runtime allowlist, so the agent's own tool policy decides what it can
call. The prompt stays hidden from the chat as before.

No caller passes a prompt yet, so the existing Template opening and New
agent onboarding still run without tools.

* fix(plugins): preserve exact package identity in tool inventory

* feat(templates): finish Add through retryable hidden setup

* docs(templates): reconcile chat Add manifest and heartbeat limits

* fix(templates): present setup cards without redundant narration

* fix(templates): preserve incomplete dependency results through setup retry

* fix(templates): keep setup retry outcomes truthful independently

* fix(templates): attach chat while dependency setup settles

* test(chat): provide submission owners to chat fixtures

* docs(templates): cite concurrent setup prompt incident

* fix(templates): keep Add timing diagnostics at debug level

* test(ui): supply submissions owner to plugin identity fixture

* fix(ui): retain Template Retry input across reconnects

* test(ui): share Template live-custody scenarios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL 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.

1 participant