Skip to content

fix(templates): empty agent overrides silently select a default - #192934

Merged
obviyus merged 2 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/templates-empty-override
Nov 4, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/templates-empty-override

Conversation

@zhangguiping-xydt

@zhangguiping-xydt zhangguiping-xydt commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

templates dev and templates add --agent-id "" silently discard the explicitly empty override and select an automatically numbered agent ID instead of returning the planner's existing portable-ID validation error.

User Impact

An explicitly empty agent ID produces the existing invalid_agent_id blocker and exit 1. Omitting the flag still selects the next unused template copy; a valid explicit ID remains unchanged. No new option, validator, default policy, schema, permission, or migration.

Why This Change Was Made

Forward the supplied value unchanged through both CLI adapters and default only nullish IDs in buildTemplateAddPlan. Its existing portable-ID validator owns rejection, before installation can proceed. This completes the Add/dev side of the explicit-empty defect class previously fixed for creation in #192726, while retaining the numbering behavior from #171623.

Preserves @zhangguiping-xydt's original fix commit and credit. The dev regression reuses the real authoring/build/preview fixture; the Add regression shares its existing package-identity matrix. Gateway-readiness setup is consolidated while retaining immediate readiness, cached/applied revisions and deadline/error coverage. The allocation file is removed. Whole-PR deltas: production +5/-5 (net 0, ten gross changed lines), tests +55/-55 (net 0), docs +3.

Evidence

Built public CLI proof and twelve captured preview outcomes.

Both current main ae402b4faf99178ff433094b0e9798885145c420 and candidate production bee92fa45c94f0d58fa937b16c908dab6b218a5b were runtime-built and exercised through shipped openclaw.mjs in secretless Node 24.22.1 Docker, with explicit owned profiles, HOME/state/config and database paths. Final head 76967828d717b0258dae82fc5d2bdd6bf2bf9aa3 changes only tests and allocation removal afterward.

For BOTH dev and Add dry-run, existing configured IDs proof-agent and proof-agent-2 force genuine automatic selection of proof-agent-3:

Input Main Candidate
--agent-id "" exit 0, finalId proof-agent-3 exit 1, finalId empty, invalid_agent_id, blocked agent action
flag omitted exit 0, finalId proof-agent-3 unchanged
--agent-id chosen-agent exit 0, finalId chosen-agent unchanged

Configuration bytes remain unchanged after every case; all destination workspaces and workspace-action targets remain absent. All plans have dryRun=true and mutationAllowed=false; dev is offline. This is preview/planner proof only: no full Add installation, model turn, Gateway, external provider, or live credentials.

72 focused tests pass. The two adapter regressions fail on main, with 19 CLI controls passing. Focused changed-test typechecking, typed lint, the final failure-assertion cases and formatting of all six changed files pass. No test allocation or baseline increase.

Merge danger

Two-way door: reverting restores the previous empty-override defaulting. No existing agent or stored format is changed, and no migration is needed. Blast radius is explicit empty identity overrides reaching Template Add/dev planning. Omission, automatic numbering, valid overrides, installation ownership and ordinary failures remain unchanged; full Add installation was not exercised by this proof.

@clawsweeper

clawsweeper Bot commented Nov 4, 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 docs Improvements or additions to documentation cli CLI command changes size: XS labels Nov 4, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 4, 2026
@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Preserve explicitly empty agent-ID overrides so Templates Add and dev reject them through existing planner validation.

Example: Run templates add PROJECT --dry-run --agent-id "" with proof-agent and proof-agent-2 already configured.

  • Before: Succeeds with automatically selected ID proof-agent-3.
  • After: Exits 1 with invalid_agent_id and a blocked agent action.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused production repair with public-CLI before/after evidence, distinct adapter regressions, preserved controls, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied secretless Node Docker output exercises shipped openclaw.mjs through dev and Add dry-run on main and candidate: empty overrides produce invalid_agent_id and exit 1, omitted overrides retain collision-driven proof-agent-3 selection, and valid chosen-agent overrides remain unchanged; configuration and destination observations confirm preview-only behavior, and the final head has identical production code.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An empty --agent-id value silently chooses an automatic destination instead of reporting invalid input.
Reason: The change restores existing portable-ID validation while preserving omitted and valid overrides, with no new option or product policy.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current Templates CLI bug with a focused change; no actionable defects were found, and ordinary CI remains pending.

Priority: P2
Reviewed head: 76967828d717b0258dae82fc5d2bdd6bf2bf9aa3

Before merge

None.

Findings

None.

Agent review details

How this fits together

Templates CLI adapters pass package content, destination overrides, and configured resource identities to the shared Add planner, which returns diagnostics and actions before installation.

flowchart TD
  A[Templates CLI input] --> B[Add adapter]
  A --> C[Dev adapter]
  B --> D[Shared Add planner]
  C --> D
  D --> E[Existing portable ID validator]
  E --> F[Blocked preview or valid plan]
Loading

Technical review

Best possible solution:

Land the existing adapter forwarding and nullish planner defaulting after required CI completes.

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

Current-main source discards empty overrides in both adapters and the planner; the supplied built-CLI comparison independently demonstrates the resulting automatic selection.

Is this the best way to solve the issue?

This is the smallest complete fix: preserve caller input at both adapters and let the existing planner validator distinguish invalid emptiness from omission.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Shared planner automatic numbering changes intended behavior with a stated reason (81662c5: Create ordinary agents with automatically numbered unused IDs on repeated Add operations.)
  • Dev CLI override forwarding changes intended behavior with a stated reason (7422222: Provide the local project authoring, build, and offline preview lifecycle; the original adapter used truthy optional-value forwarding.)
  • Add CLI override forwarding changes intended behavior with a stated reason (138d2a5: Expose grouped manifest inspection and read-only Add planning with destination overrides and portable-ID validation.)
  • Gateway readiness test consolidation keeps the original intent (f6479d2: Keep readiness preparation with the Add command owner; consolidation retains immediate readiness, cached revisions, and deadline/error cases.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 5af1093 adds src/cli/claws-cli.project.ts:184 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5af109365289; files: src/cli/claws-cli.project.ts)
  • Gio Della-Libera: Raw commit 138d2a5 adds src/claws/lifecycle.ts:127 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 138d2a56274c; files: src/claws/lifecycle.ts)

PR surface

Source 0, Tests 0, Docs +3. Total +3 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 5 5 0
Tests 2 55 55 0
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 63 60 +3

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: Explicitly empty identity variables silently select an unintended agent destination in a bounded advanced CLI workflow.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 (1 earlier review cycle)
  • reviewed 2026-11-04T18:33:53.232Z sha bee92fa :: needs maintainer review before merge. :: none

Reviewed November 4, 2026, 2:40 PM ET / 19:40 UTC (Revision 2).

@obviyus

obviyus commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Nov 4, 2026
@obviyus

obviyus commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Built public CLI: empty overrides rejected, automatic numbering preserved

Exact PR head: 76967828d717b0258dae82fc5d2bdd6bf2bf9aa3. Frozen main: ae402b4faf99178ff433094b0e9798885145c420. Candidate production was built from contributor commit bee92fa45c94f0d58fa937b16c908dab6b218a5b; later changes only consolidate tests and remove the allocation. Both refs were installed/runtime-built and exercised in secretless node:24.22.1 Docker through shipped openclaw.mjs, with no imported planner or mocked owner.

The fixture creates a synthetic project through the real templates create PROJECT --name proof-template --agent-id proof-agent --json command. An owned config enables Templates Labs and explicitly configures existing IDs proof-agent and proof-agent-2, forcing a real collision-driven automatic selection of proof-agent-3. It uses the normal explicit-roster/surface-owner settings, no Doctor command or product/config-schema changes. Every process passes its explicit profile plus isolated HOME, OPENCLAW_HOME, state and config paths. That exact binary reports its config and session database under /work/runs/task192934-{base,cand}-explicit/. Temporary artifact storage is also task-owned.

For EACH ref, the public commands are exercised with an empty flag, omitted flag, and valid chosen-agent override:

node openclaw.mjs --profile <owned> templates dev PROJECT --agent-id "" --json
node openclaw.mjs --profile <owned> templates add PROJECT --dry-run --agent-id "" --json

The controls replace the empty flag with omission or --agent-id chosen-agent. No Add invocation omits --dry-run.

Main silently returns proof-agent-3, exit 0, for both explicitly empty inputs. Candidate returns finalId: "", the existing invalid_agent_id blocker and blocked agent action, exit 1. Both commands on both refs still select proof-agent-3 when omitted and exactly chosen-agent when explicitly valid.

Actual output/readback fields from all twelve cases:

[
  {
    "lane": "base",
    "case": "dev-empty",
    "exit": 0,
    "finalId": "proof-agent-3",
    "blockerCodes": [],
    "configUnchanged": true,
    "destinationWorkspaceExists": false,
    "previewOnly": true
  },
  {
    "lane": "base",
    "case": "dev-omitted",
    "exit": 0,
    "finalId": "proof-agent-3",
    "blockerCodes": [],
    "configUnchanged": true,
    "destinationWorkspaceExists": false,
    "previewOnly": true
  },
  {
    "lane": "base",
    "case": "dev-valid",
    "exit": 0,
    "finalId": "chosen-agent",
    "blockerCodes": [],
    "configUnchanged": true,
    "destinationWorkspaceExists": false,
    "previewOnly": true
  },
  {
    "lane": "base",
    "case": "add-empty",
    "exit": 0,
    "finalId": "proof-agent-3",
    "blockerCodes": [],
    "configUnchanged": true,
    "destinationWorkspaceExists": false,
    "previewOnly": true
  },
  {
    "lane": "base",
    "case": "add-omitted",
    "exit": 0,
    "finalId": "proof-agent-3",
    "blockerCodes": [],
    "configUnchanged": true,
    "destinationWorkspaceExists": false,
    "previewOnly": true
  },
  {
    "lane": "base",
    "case": "add-valid",
    "exit": 0,
    "finalId": "chosen-agent",
    "blockerCodes": [],
    "configUnchanged": true,
    "destinationWorkspaceExists": false,
    "previewOnly": true
  },
  {
    "lane": "cand",
    "case": "dev-empty",
    "exit": 1,
    "finalId": "",
    "blockerCodes": [
      "invalid_agent_id"
    ],
    "configUnchanged": true,
    "destinationWorkspaceExists": false,
    "previewOnly": true
  },
  {
    "lane": "cand",
    "case": "dev-omitted",
    "exit": 0,
    "finalId": "proof-agent-3",
    "blockerCodes": [],
    "configUnchanged": true,
    "destinationWorkspaceExists": false,
    "previewOnly": true
  },
  {
    "lane": "cand",
    "case": "dev-valid",
    "exit": 0,
    "finalId": "chosen-agent",
    "blockerCodes": [],
    "configUnchanged": true,
    "destinationWorkspaceExists": false,
    "previewOnly": true
  },
  {
    "lane": "cand",
    "case": "add-empty",
    "exit": 1,
    "finalId": "",
    "blockerCodes": [
      "invalid_agent_id"
    ],
    "configUnchanged": true,
    "destinationWorkspaceExists": false,
    "previewOnly": true
  },
  {
    "lane": "cand",
    "case": "add-omitted",
    "exit": 0,
    "finalId": "proof-agent-3",
    "blockerCodes": [],
    "configUnchanged": true,
    "destinationWorkspaceExists": false,
    "previewOnly": true
  },
  {
    "lane": "cand",
    "case": "add-valid",
    "exit": 0,
    "finalId": "chosen-agent",
    "blockerCodes": [],
    "configUnchanged": true,
    "destinationWorkspaceExists": false,
    "previewOnly": true
  }
]

All plans assert dryRun=true and mutationAllowed=false; dev additionally asserts offline=true. Independent filesystem observations confirm every planned destination workspace and workspace action target remains absent. Config bytes and SHA-256 are unchanged before/after every case. The generated source fixture is intentional setup, not an installed agent. This proves previews/plans only, not full Add installation or a model turn. No Gateway, provider or real credentials were used.

Verification: 72 focused tests pass (both CLI suites plus schema tests). The two adapter regressions fail on main, with the other 19 CLI cases passing. The final unchanged failure-assertion cases, focused changed-test typecheck, targeted typed lint, and formatting of all six changed files pass. Whole-PR deltas: production +5/-5 (net 0, ten gross lines), tests +55/-55 (net 0), docs +3; allocation removed, no baseline increase. Contributor @zhangguiping-xydt's fix commit and credit are preserved.

@obviyus

obviyus commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 4, 2026
@obviyus
obviyus merged commit 863cd7e into openclaw:main Nov 4, 2026
133 of 134 checks passed
@obviyus

obviyus commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Landed in 863cd7e. Thanks @zhangguiping-xydt. templates dev and add now reject an empty agent id.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 5, 2026
…claw#192934)

fix(templates): validate empty agent ids on templates dev and add

Like openclaw#192726 for `templates create`, an explicitly empty `--agent-id` on `templates dev` and `templates add` was silently ignored and an auto-numbered agent id was used. An explicit blank now reaches the existing portable-ID validator and is rejected. Omitted flags still auto-number, and valid ids are unchanged.

Evidence: built CLI previews for both dev and add dry-run. Main silently selected `proof-agent-3` for empty overrides; with this change they are rejected with the existing `invalid_agent_id` error and exit 1. Omitted flags still auto-number to `proof-agent-3`, valid overrides keep `chosen-agent`, and config is unchanged. Details: openclaw#192934 (comment).

Thanks @zhangguiping-xydt.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 5, 2026
…#193336)

fix(status): reject an explicit blank agent for usage

An explicitly blank `--agent` on the status usage command was dropped before validation, so the command silently showed the default agent's usage. The blank value now reaches the existing agent validator and is rejected with its existing message, as `templates` does after #192726 and #192934. Omitted, valid and unknown agents and the no-usage case are unchanged.

Evidence: built Linux CLI, text and JSON output. Main silently accepted the blank selection; with this change it is rejected in both formats. Omitted, valid, unknown-agent and no-usage controls are unchanged. Details: #193336 (comment).

Thanks @wangmiao0668000666.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
…openclaw#193336)

fix(status): reject an explicit blank agent for usage

An explicitly blank `--agent` on the status usage command was dropped before validation, so the command silently showed the default agent's usage. The blank value now reaches the existing agent validator and is rejected with its existing message, as `templates` does after openclaw#192726 and openclaw#192934. Omitted, valid and unknown agents and the no-usage case are unchanged.

Evidence: built Linux CLI, text and JSON output. Main silently accepted the blank selection; with this change it is rejected in both formats. Omitted, valid, unknown-agent and no-usage controls are unchanged. Details: openclaw#193336 (comment).

Thanks @wangmiao0668000666.

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

Labels

cli CLI command changes docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. 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