Skip to content

feat(templates): finish Add in a retryable setup conversation - #198603

Merged
Patrick-Erichsen merged 48 commits into
mainfrom
template-setup-delivery-integrated
Nov 16, 2026
Merged

Patrick-Erichsen merged 48 commits into
mainfrom
template-setup-delivery-integrated

Conversation

@Patrick-Erichsen

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

Copy link
Copy Markdown
Contributor

What problem this solves

Template Add can create the agent but its tools-disabled opening cannot finish the declared setup or recover a failed opening without repeating creation.

What changes

After creation, one hidden setup turn uses the new agent’s ordinary tools and retained permissions. It greets in the Template’s voice, creates declared automations paused, reports MCP sign-in needs, and shows exact-package plugin cards without installing or enabling those plugins. Explicit tool denies and operator ceilings remain authoritative.

The ordinary session owns the retryable setup continuation. Retry uses the same agent, workspace and conversation without reinstalling dependencies. When its one-shot receipt has already been consumed, Retry returns a truthful partial/unverifiable outcome instead of inventing readiness or creating another agent. Plugin inventory includes canonical package identity so the agent does not infer a plugin ID from its package name.

This layer follows #198070. Early-opening/dependency concurrency and composer responsiveness remain a separate follow-up.

Evidence

Current repair qualification

Head 577e12a6b457945be951b6e97a753b9c2cfebaef, base 9ed5a58794db142be41f5e142e68a5cd92d72bd0:

  • Promotes the existing stale/concurrent Retry fix into this independently landable layer. Three Gateway regression cases fail before the fix with false complete/ready results. After the fix the complete owning request suite passes 14/14, exit0 (144.61s wrapper): node scripts/test-projects.mts src/gateway/server-methods/templates-add-chat.integration.test.ts --maxWorkers=1. The same agent, workspace, edited files and dependency-install counts are preserved. External registry/model I/O is fixed; admission, config, workspace, session, rollback and retained setup ownership remain real. No new test seam or mock was introduced.
  • Moves the unchanged setup input contract into a type-only leaf and updates all three consumers. Both runtime and Madge import-cycle guards now report zero cycles. The leaf does not prematurely add the responsive follow-up callbacks.
  • Adds the incident reference beside the bootstrap exception, without changing model-facing prompt bytes.
  • Six-file type-aware lint, formatting and diff checks pass. Test-line ratchet is +281 <=400, no setup allocation or global-limit changes.
  • Seven existing setup commits were restacked onto the creation allocation-only repair. UI source and performance inputs are unchanged from the prior setup qualification below; prior results are reused, not claimed as fresh executions. Exact-head hosted compiler/build/CI and completed re-review remain required.

Retained prior qualification

Prior setup e68f2ecdbc3b54fea242e6ca545d1f0830bc0aff above b7235cc095dff0eebd90cd268b2695ca96f98a08:

  • Complete strict paired production-UI performance passes, exit0: document 14,019 B <=14,026 B; chat JS 1,315,006→1,315,005 B, New Session 818,001→818,000 B, startup 90,860 B unchanged. Requests and CSS unchanged. Command: node --import ./scripts/tsx.mjs scripts/check-control-ui-performance-base.mts b7235cc095dff0eebd90cd268b2695ca96f98a08.
  • Owning Gateway14/14 and setup prompt6/6, complete two-shard command exit0 (161.15s). Explicit denies and operator ceilings remain authoritative.
  • Deletes the old tools-disabled outcome prompt and uses the existing session continuation owner, not a parallel Template ledger.

The prior hosted native Talk and UI failures were compared with scheduled main run43540514362 and have identical failure signatures; they are not passing CI. New-head checks still need reconciliation. No inherited-failure qualification covers an introduced defect.

Real product evidence and remaining gap

Earlier integrated Travel Copilot proof, not this exact head: baseline creation opened chat at19.9s, failed on a disabled referenced plugin at35.6s, leaving an empty workspace. Earlier integrated creation/setup opened pending chat in104ms and produced output at52.2s, preserving original CLAW.md and goplaces while leaving Expedia disabled and Travel Themes uninstalled. The later retained responsiveness recording showed the original-chat card without narration and working review navigation without installation; that follow-up is not part of this PR.

These historical screenshots do not prove the current setup head, completed plugin installation, latest-stable upgrade preservation, or final combined-head video. The historical live-card omission is addressed by the current foundation and its three producer-to-renderer paths. Fresh combined-head real Add/install/caption/video proof remains open before final delivery. No production Gateway was changed.

Before: disabled plugin leaves setup failed and workspace empty

Earlier integrated creation/setup, not current-head proof

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.
@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Nov 14, 2026
Keep both the chat-mode routing test and main's authored MCP declaration
test in templates-add.test.ts.
Base automatically changed from template-add-chat-creation to main November 16, 2026 02:32
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes scripts Repository scripts labels Nov 16, 2026
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 9ecffa2f40b5b6c61e573023bfb78faaf3849fb7
  • Maintainer: @Patrick-Erichsen
  • Repository role: maintain

These security sensitive changes were made:

  • src/gateway/server-methods/cron-creator-authority-admission.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

The squash commit's tree equals the merge of its parent with the creation
head this branch already contains, so this branch's tree is unchanged.
@openclaw-barnacle openclaw-barnacle Bot removed cli CLI command changes scripts Repository scripts labels Nov 16, 2026
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor Author

Setup, Retry and upgrade evidence for the build that contains this layer

This answers the proof requests in the review of 577e12a6b457. The runs below used the combined Template Add stack (production build 4a4f2f1c80f9, source eae4a00827b6), which contains this layer together with the creation layer below it (now on main as #198070) and the responsive, copy and actions layers above it. They were not taken on this layer alone and predate the merges with current main; exact-head CI covers the merged code.

Setup turn with a real model and plugin card

Real Control UI Add of @jjjhenriksen/[email protected], with Expedia installed but disabled, against an isolated real Gateway and a real provider:

  • The first turn is the hidden setup run agents.create:travel-copilot:template-setup:…. It ended in state final, and setup completion was observed from that run's own terminal event. Add returned complete with initialization finished.
  • Measured from the Add click: chat visible at 75 ms, first assistant text at 16.9 s, first turn finished at 34.5 s.
  • The opening reply reports the dependency outcome: "The Expedia plugin is installed but disabled. If you'd like to use it, ask me to enable it."
  • One plugin card rendered in the chat, for Travel Themes, with an Install action and no Dismiss button. Opening its details did not install it; a later explicit plugins.install from the details page succeeded and left the plugin installed and enabled.
  • No alerts, toasts, consent dialogs, console errors or unanswered Template calls remained at the end.

This Template declares no automations, so this run does not show a paused automation.

Failed opening, then Retry on the same agent

The paired before/after run for a failed opening turn followed by a cold Gateway restart is in #198637 (comment). After the provider was restored and the Gateway cold-restarted, Retry completed the same agent and session with resume: true. Exactly one queued send went out with its attachment, the unsent draft and its attachment stayed in the composer, and no second Add was needed.

Latest-stable upgrade keeps existing data

An isolated Gateway ran official [email protected] (state schema 22, agent schema 27) and created an ordinary session. The candidate build then opened the same state directory: doctor migrated state 22→40 and agent 27→42 and exited 0. After the upgrade and again after a cold restart, the stored session keeps its sessionId, label and session root, has none of the Template setup fields, and the five workspace files have identical SHA-256 values. The Control UI opens the session with an editable composer.

The same comment linked above also describes a four-process real-SQLite round trip of the new setup receipt fields (write, cold read, clear, cold read after clear).

What this does not show

  • No transcript comparison across the upgrade, because the stable Gateway had no usable provider credential.
  • No run of an older runtime reading session records that already carry the new setup fields.
  • No live demonstration of setup resuming on its own after a restart; Retry was user-initiated.

Screenshots and recordings of these runs are retained locally and have been inspected. They are not attached here because the attachment route had no authenticated browser session.

@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:feature Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 16, 2026
@Patrick-Erichsen
Patrick-Erichsen merged commit c365366 into main Nov 16, 2026
260 of 263 checks passed
@Patrick-Erichsen
Patrick-Erichsen deleted the template-setup-delivery-integrated branch November 16, 2026 03:35
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 setup 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 16, 2026
…aw#198603)

* 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
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 docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. security-sensitive-changed 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