Skip to content

fix(agents): import identity from literal source paths - #186475

Merged
obviyus merged 3 commits into
openclaw:mainfrom
Alix-007:alix/fix-identity-literal-path-20261028
Oct 28, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
Alix-007:alix/fix-identity-literal-path-20261028

Conversation

@Alix-007

@Alix-007 Alix-007 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

agents set-identity trims nonblank --identity-file and --workspace source selectors. On filesystems supporting leading or trailing spaces, that can import the identity from a different, neighboring path and save the wrong agent identity.

User Impact

Quoted source paths select the exact file or directory. Empty or whitespace-only selectors still fail, and importing from another directory does not relocate the configured workspace.

Why This Change Was Made

Use existing nonblank-string validation and home-prefix expansion in this command's local resolver without trimming valid filename bytes. Global path decoding, identity parsing, scalar identity fields, config schema, and the config writer remain unchanged.

Evidence

Observed runtime capture.

Built CLI on Linux arm64, Node 24.22.1, with isolated task-owned HOME, profile, state and config. Each case independently reads the saved JSON config after agents set-identity --agent main ... --json.

Source selector Current main, twice Candidate, twice
File with trailing space Wrong neighbor Exact file
File with leading space Wrong neighbor Exact file
Workspace with trailing space Wrong neighbor Exact directory
Workspace with leading space Wrong neighbor Exact directory
  • Both refs pass ordinary absolute, relative, ~/ home-expanded, symlink, and ordinary workspace controls.
  • Blank and missing file/workspace selectors fail with byte-identical config. Successful imports preserve both configured workspace values.
  • Focused identity suite: 21 passed. The same two literal-source regression cases fail on main by importing the wrong neighbor. Focused Oxlint and Oxfmt passed; git diff --check passed.

Simplification: reuse the existing command owner and helpers; no new abstraction or global decoder change. Production +9/-5, regression tests +34, docs +1; no test baseline raised.

Two-way door: reverting restores path trimming; no migration or new stored format. It cannot automatically undo identities previously imported from a wrong source. Blast radius is source-path selection for agents set-identity, not agent routing or other path consumers.

@clawsweeper

clawsweeper Bot commented Oct 28, 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 commands Command implementations size: XS labels Oct 28, 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: 🦞 diamond lobster Very strong PR readiness with only minor 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 Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Preserve leading and trailing whitespace in nonblank identity-file and workspace source paths.

Example: Run agents set-identity --agent main --identity-file "/tmp/identity.md " when both neighboring files exist.

  • Before: Imports the identity from /tmp/identity.md.
  • After: Imports the identity from /tmp/identity.md followed by a space.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused, correct repair with relevant built-CLI proof, distinct regression coverage, and successful reviewed-head CI; existing persisted formats and write behavior are unchanged.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Obviyus records the built CLI on isolated Linux arm64 with Node 24.22.1 exercising candidate production code matching this head: both selectors import the exact leading/trailing-space source, saved config confirms the identity, configured workspaces remain unchanged, ordinary paths succeed, and blank or missing sources leave config unchanged.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A quoted filename or directory containing leading or trailing spaces can import a different neighboring identity and save it to the selected agent.
Reason: Exact source selection is an existing CLI expectation, and the narrow repair preserves the established blank-input and workspace-retention contracts.

Merge readiness

✅ Ready for maintainer review

This PR fixes a concrete wrong-source identity import still present on current main; the focused implementation has no actionable findings.

Priority: P2
Reviewed head: 24db90234c4002afc2bcedbdb51647e6ea7c34f9

Before merge

None.

Findings

None.

Agent review details

How this fits together

The CLI identity command resolves an operator-selected source, reads identity fields, and updates the selected agent through the existing config mutation owner.

flowchart LR
  A[CLI source flags] --> B[Nonblank validation]
  B --> C[Literal path and home expansion]
  C --> D[Identity file reader]
  D --> E[Agent config mutation]
  E --> F[Saved config and CLI output]
Loading

Technical review

Best possible solution:

Merge the focused selector fix through the existing identity command and config writer.

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

Current-main source shows both trimming layers, and obviyus supplies repeated built-CLI wrong-neighbor reproductions against the pinned baseline; no target code was executed during this review.

Is this the best way to solve the issue?

The patch is the smallest complete fix: preserve nonblank selector bytes at validation and resolution while retaining home expansion, blank rejection, identity parsing, and the existing write owner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Source-selector trimming and local path resolution changes intended behavior with a stated reason (fcea630: The original identity helper normalized all optional strings and resolved paths through resolveUserPath; the later helper-reader refactor preserved this normalization.)
  • Shared normalization package imports keeps the original intent (00d8d7e: Extract shared normalization helpers into the private normalization-core package while retaining existing public boundaries.)
  • Blank-input rejection and source-locator documentation keeps the original intent (fix(cli): reject blank agent identity path flags #182622: Reject explicitly blank selectors before fallback or config writes; preserve the earlier distinction between source locators and stored workspaces.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Pierre-Louis Manchuelle--Lambré: Raw commit 4c4144d adds src/commands/agents.commands.identity.ts:163 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4c4144d5ae68; files: src/commands/agents.commands.identity.ts)
  • wangmiao0668000666: Raw commit e61931e adds src/commands/agents.commands.identity.ts:60 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e61931e664fd; files: src/commands/agents.commands.identity.ts)

PR surface

Source +4, Tests +34, Docs +1. Total +39 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 9 5 +4
Tests 1 34 0 +34
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 44 5 +39

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +9/-5; tests +34/-0 Small helper substitutions repair both selectors, with one parameterized regression covering their distinct file and workspace branches.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Quoted paths containing boundary whitespace can silently import a neighboring identity, with impact limited to this explicit CLI operation.
  • 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-10-28T03:38:09.205Z sha 5d9d512 :: needs maintainer review before merge. :: none

Reviewed October 28, 2026, 12:33 AM ET / 04:33 UTC (Revision 2).

@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Current-head built CLI proof on Linux arm64, Node v24.22.1. Baseline main: d79a7b6c371c8b37938d412a2015b2545f6699db; candidate production code matches 24db90234c4002afc2bcedbdb51647e6ea7c34f9 (the additional commit documents the selector contract).

Commands used the built entry point, isolated profile/HOME/state/config, and independent saved-config readback:

openclaw --profile <isolated> agents set-identity --agent main --identity-file "<fixture>/identity.md " --json
openclaw --profile <isolated> agents set-identity --agent main --workspace "<fixture>/source " --from-identity --json

case                        main repeat1/repeat2            candidate repeat1/repeat2
file trailing space         WRONG_NEIGHBOR / WRONG_NEIGHBOR RIGHT_LITERAL_FILE / RIGHT_LITERAL_FILE
file leading space          WRONG_NEIGHBOR / WRONG_NEIGHBOR RIGHT_LEADING_FILE / RIGHT_LEADING_FILE
workspace trailing space    WRONG_WORKSPACE_NEIGHBOR twice  RIGHT_LITERAL_WORKSPACE twice
workspace leading space     WRONG_WORKSPACE_NEIGHBOR twice  RIGHT_LEADING_WORKSPACE twice

Each successful import left the configured workspace unchanged. Ordinary absolute and relative files, home expansion, a symlink, and ordinary workspace imports passed on both refs. Blank and missing file/workspace selectors exited 1 with byte-identical config.

Focused tests: 21 passed on candidate; the same two new literal-source cases fail on main by selecting the wrong neighbor. Focused formatting/lint and whitespace checks passed. No Gateway, model credential, schema change, or global decoder change was involved.

@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 28, 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 28, 2026
@obviyus
obviyus merged commit 2cb6180 into openclaw:main Oct 28, 2026
126 of 131 checks passed
@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Landed in 2cb6180. Thanks @Alix-007. set-identity now imports from the exact path given.

@Alix-007

Copy link
Copy Markdown
Contributor Author

Thanks @obviyus for reviewing this and running the extra verification!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 29, 2026
fix(agents): import identity from literal source paths

`openclaw agents set-identity` trimmed the file and workspace source selectors, so a selector whose path starts or ends with whitespace resolved to a different, neighboring path and imported the wrong identity. Selectors are now used as written; blank and missing selectors behave as before.

Evidence: built CLI on Linux with identity files named so that trimming selects the neighbor. On main leading and trailing file and workspace selectors imported the wrong identity (twice); with this change they imported the exact one (twice). Ordinary, relative, home, blank and missing selectors behave the same on both refs. Production 14 lines.

Thanks @Alix-007.

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

commands Command implementations 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: XS 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