Skip to content

fix(agents): clear emoji/avatar on agents.update empty or null - #120052

Closed
jackoconner45 wants to merge 3 commits into
openclaw:mainfrom
jackoconner45:fix/agents-update-clear-identity
Closed

jackoconner45 wants to merge 3 commits into
openclaw:mainfrom
jackoconner45:fix/agents-update-clear-identity

Conversation

@jackoconner45

Copy link
Copy Markdown

Closes #119929

AI-assisted contribution: drafted with the help of an AI coding agent; tests and typechecks in Evidence were run against the exact head commit.

What Problem This Solves

Fixes an issue where operators who clear an agent's emoji or avatar in the Control UI (or via the agents.update gateway method) would see the previous value silently kept. Empty strings were compacted away by createAgentIdentityConfig, so the identity patch was omitted entirely and the prior emoji/avatar survived — there was no way to clear either field, unlike model, which already supports a null clear path.

Why This Change Was Made

Explicit empty string or null for emoji/avatar now acts as a clear tombstone, mirroring the existing model: null semantics:

  • The update schema accepts null alongside empty string for both fields.
  • agents.update builds the identity patch through a new buildAgentIdentityUpdatePatch, keeping an explicit emoji: "" / avatar: "" tombstone instead of compacting it away.
  • The tombstone flows end-to-end: the agent config entry is merged with the cleared value, and IDENTITY.md is rewritten to remove the cleared field's line (previously the stale line survived in the file even when config changed).
  • Omitted fields keep their stored values; the create path is untouched.

User Impact

Operators can now clear an agent's emoji or avatar by updating with an empty value (as the Control UI already sends on clear) or with null — consistent with model: null. Clearing persists to both the agent config and IDENTITY.md, so the cleared state survives reloads and reconnect identity fetches.

Evidence

Focused suites pass on the exact head commit (148 tests):

  • src/agents/identity-file.test.ts (19) — patch-builder clear semantics and IDENTITY.md line deletion
  • src/gateway/server-methods/agents-mutate.test.ts (99) — agents.update clears emoji/avatar in config and IDENTITY.md for "" and null, preserves untouched fields
  • packages/gateway-protocol/src/schema/agents-models-skills.test.ts (30) — schema accepts empty/null emoji/avatar

Typechecks: tsgo:core clean; scoped tsgo checks of all touched prod and test files clean. Full repo lanes run on CI (this environment is below the repo's Node floor of 22.22.3).

Note: issue #119929 currently has a draft PR open (#119930) awaiting a maintainer product decision; this PR lands the same fix with an end-to-end tombstone through both config and IDENTITY.md.

@jackoconner45
jackoconner45 marked this pull request as ready for review August 6, 2026 22:21
@jackoconner45

Copy link
Copy Markdown
Author

Reopening to re-fire the pull_request CI run that did not attach on open.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 57c9b15586

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +941 to 944
const identity = buildAgentIdentityUpdatePatch({
name: safeName,
emoji: params.emoji,
avatar: params.avatar,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Wire clear tombstones through the Control UI

When the clear starts from the shipped Control UI, it still cannot reach this new server path: ui/src/pages/agents/identity-actions.ts:71-77 returns for blank emoji edits, and ui/src/lib/agents/index.ts:219-224 omits falsy emoji/avatar fields before calling agents.update. The raw gateway method now accepts ""/null, but the default operator client remains on the old no-clear behavior, so users still cannot clear these fields from the UI.

AGENTS.md reference: AGENTS.md:L147-L147

Useful? React with 👍 / 👎.

Comment on lines +255 to +258
if (value === "") {
// Explicit empty removes the stored line; duplicated labels all go.
const clearedIndexes = nextLines.reduce<number[]>((indexes, line, index) => {
if (matchesIdentityLabel(line, label)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear unbulleted identity labels too

For an IDENTITY.md that uses parser-accepted unbulleted fields such as Emoji: 🙂 or Avatar: avatars/a.png, an agents.update clear reports success but leaves the stale line in the file because this new clear branch only deletes lines matched by matchesIdentityLabel, which requires a leading -. Since file identity is still read as a fallback after the config tombstone, the old emoji/avatar can reappear in list or assistant identity surfaces after a supposed clear.

AGENTS.md reference: AGENTS.md:L47-L47

Useful? React with 👍 / 👎.

@openclaw-barnacle openclaw-barnacle Bot closed this Aug 6, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Aug 6, 2026
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: M labels Aug 6, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 6, 2026, 8:30 PM ET / August 7, 2026, 00:30 UTC.

ClawSweeper review

What this changes

This PR changes agent updates so empty or null emoji/avatar values become identity-clear tombstones and are removed from the rewritten identity file.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 10 items remain

Keep open: the gateway repair is incomplete on the default Control UI path, parser-accepted unbulleted identity fields remain stale, and the public SDK cannot type null clears.

Priority: P2
Reviewed head: d6f4881c5ea2c3f43e113bb5035d5a57f7305dbe
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch has a sound gateway direction but leaves three concrete user-visible contract boundaries incomplete and has only mock-level proof.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The body reports focused unit and handler suites, but provides no inspectable after-fix Control UI or production-boundary behavior proof; add a redacted mocked-Gateway UI flow or equivalent end-to-end evidence. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦪 silver shellfish (2/6) 3 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The body reports focused unit and handler suites, but provides no inspectable after-fix Control UI or production-boundary behavior proof; add a redacted mocked-Gateway UI flow or equivalent end-to-end evidence. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Control UI clear is still unreachable: Blank emoji edits return before dispatch, payload construction omits falsy emoji/avatar fields, and avatar has no remove action; the first-party operator flow therefore cannot reach this PR's tombstones.
Unbulleted identity labels survive a clear: The identity parser accepts optional bullets, but the changed clear branch uses a matcher that rejects lines without a leading bullet, leaving a reader-accepted stale Emoji or Avatar value.
SDK type does not expose the nullable protocol contract: The PR makes the gateway schema accept null while the public SDK still declares emoji and avatar as string-only, preventing TypeScript consumers from sending the intended clear value.
Findings 3 actionable findings [P1] Carry clear tombstones through the Control UI
[P2] Clear unbulleted identity labels too
[P2] Expose nullable clears in the public SDK type
Security None None.

How this fits together

The Control UI sends agent identity edits through the gateway, which merges agent configuration and rewrites IDENTITY.md. Agent list and assistant identity readback can use both configuration and the workspace identity file.

flowchart LR
  Edit[Operator identity edit] --> UI[Control UI]
  UI --> Request[Gateway update request]
  Request --> Schema[Protocol validation]
  Schema --> Config[Agent configuration merge]
  Config --> Identity[Identity file rewrite]
  Identity --> Readback[Agent identity readback]
Loading

Decision needed

Question Recommendation
Should agents.update retain legacy empty-string omission semantics and make null the sole clear tombstone, or intentionally make both null and empty strings clear stored identity? Use null as the canonical clear: Keep empty strings as omission-compatible and have the Control UI and SDK send null for explicit clears.

Why: The branch changes a public gateway input from a no-op-like omission to a persisted clear, so the compatibility contract needs explicit maintainer intent before the mechanical fixes are finalized.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The body reports focused unit and handler suites, but provides no inspectable after-fix Control UI or production-boundary behavior proof; add a redacted mocked-Gateway UI flow or equivalent end-to-end evidence. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Carry clear tombstones through the Control UI (P1) - This changed gateway path remains unreachable from the first-party editor: blank emoji returns before dispatch, falsy fields are omitted from the request, and avatar has no remove action. Use a tri-state draft so explicit clears send the chosen tombstone while untouched fields remain omitted.
  • Clear unbulleted identity labels too (P2) - The parser accepts Emoji: and Avatar: without bullets, but this deletion branch uses a matcher that rejects them. A successful clear can therefore leave the old value in IDENTITY.md, which downstream identity readback can surface again.
  • Expose nullable clears in the public SDK type (P2) - The protocol now accepts null, but the SDK still exposes emoji/avatar as string only. TypeScript SDK clients cannot issue the intended clear request; update the public type and add a focused contract test.
  • Resolve merge risk (P1) - Existing programmatic callers that send empty strings currently get omission semantics; treating those inputs as clears changes their persisted identity behavior.
  • Complete next step (P2) - The three code repairs are bounded, but a maintainer must first choose the backward-compatibility meaning of empty-string gateway inputs.
  • Improve patch quality - Implement and test the Control UI tri-state clear flow for blank emoji and avatar removal.
  • Improve patch quality - Make deletion match every parser-accepted identity label form and cover an unbulleted file through agents.update.
  • Improve patch quality - Post redacted after-fix UI or Gateway-boundary evidence; a PR-body update can trigger fresh review.

Findings

  • [P1] Carry clear tombstones through the Control UI — src/gateway/server-methods/agents.ts:941-945
  • [P2] Clear unbulleted identity labels too — src/agents/identity-file.ts:255-265
  • [P2] Expose nullable clears in the public SDK type — packages/gateway-protocol/src/schema/agents-models-skills.ts:129-130
Agent review details

Security

None.

PR surface

Source +42, Tests +148. Total +190 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 52 10 +42
Tests 3 148 0 +148
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 200 10 +190

Review metrics

Metric Value Why it matters
Public update contract 2 fields changed to accept null Emoji and avatar are gateway API inputs, while the SDK remains string-only in this branch.
Production versus test LOC production +52/-6, tests +148/-0 The production growth is for the new clear flow, but current coverage omits the UI, SDK, and unbulleted-reader boundaries.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/server-methods/agents-mutate.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Set and test the clear contract before merge (recommended)
    Choose whether legacy empty strings clear or preserve identity, then align the UI, SDK, gateway tests, and upgrade-facing behavior with that contract.
  2. Accept the empty-string behavior change
    Merge only if maintainers intentionally accept that existing callers sending empty strings will now clear persisted identity fields.

Technical review

Best possible solution:

Choose the public empty-string contract, then land one end-to-end repair that uses a tri-state Control UI draft, aligns identity-file deletion with its parser, and exports the selected nullable contract through the SDK.

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

Yes, at source level: current main compacts empty identity values away, and the PR still visibly leaves unbulleted parser-accepted file fields and first-party UI clears unreachable.

Is this the best way to solve the issue?

No. The gateway tombstone is an appropriate owner boundary, but this branch omits the first-party client and SDK contracts and disagrees with the identity file reader grammar.

Full review comments:

  • [P1] Carry clear tombstones through the Control UI — src/gateway/server-methods/agents.ts:941-945
    This changed gateway path remains unreachable from the first-party editor: blank emoji returns before dispatch, falsy fields are omitted from the request, and avatar has no remove action. Use a tri-state draft so explicit clears send the chosen tombstone while untouched fields remain omitted.
    Confidence: 0.99
  • [P2] Clear unbulleted identity labels too — src/agents/identity-file.ts:255-265
    The parser accepts Emoji: and Avatar: without bullets, but this deletion branch uses a matcher that rejects them. A successful clear can therefore leave the old value in IDENTITY.md, which downstream identity readback can surface again.
    Confidence: 0.99
  • [P2] Expose nullable clears in the public SDK type — packages/gateway-protocol/src/schema/agents-models-skills.ts:129-130
    The protocol now accepts null, but the SDK still exposes emoji/avatar as string only. TypeScript SDK clients cannot issue the intended clear request; update the public type and add a focused contract test.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against ec023a433614.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: This PR changes empty-string gateway input from omitted identity fields to persisted clears for existing callers.

Label justifications:

  • P2: The defect affects persisted agent identity updates and the first-party editor, but does not affect agent execution or message delivery.
  • merge-risk: 🚨 compatibility: This PR changes empty-string gateway input from omitted identity fields to persisted clears for existing callers.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The body reports focused unit and handler suites, but provides no inspectable after-fix Control UI or production-boundary behavior proof; add a redacted mocked-Gateway UI flow or equivalent end-to-end evidence. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Control UI clear is still unreachable: Blank emoji edits return before dispatch, payload construction omits falsy emoji/avatar fields, and avatar has no remove action; the first-party operator flow therefore cannot reach this PR's tombstones. (ui/src/pages/agents/identity-actions.ts:71, 4d91d44d0073)
  • Unbulleted identity labels survive a clear: The identity parser accepts optional bullets, but the changed clear branch uses a matcher that rejects lines without a leading bullet, leaving a reader-accepted stale Emoji or Avatar value. (src/agents/identity-file.ts:258, d6f4881c5ea2)
  • SDK type does not expose the nullable protocol contract: The PR makes the gateway schema accept null while the public SDK still declares emoji and avatar as string-only, preventing TypeScript consumers from sending the intended clear value. (packages/gateway-protocol/src/schema/agents-models-skills.ts:129, d6f4881c5ea2)
  • Current main remains affected: Current main still routes updates through the compacting identity builder, which drops empty values before the configuration update. (src/gateway/server-methods/agents.ts:942, ec023a433614)
  • Feature history: Blame and symbol history tie the current identity parser/matcher and nearby update path to the canonical agent-creation refactor and its later identity work. (src/agents/identity-file.ts:192, 4d91d44d0073)

Likely related people:

  • steipete: Current parser, matcher, UI omission paths, and nearby gateway behavior trace to this agent-identity work in blame and history. (role: feature owner and recent identity-area contributor; confidence: high; commits: 932e8be, 4d91d44d0073; files: src/agents/identity-file.ts, src/gateway/server-methods/agents.ts, ui/src/pages/agents/identity-actions.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@vincentkoc vincentkoc added duplicate This issue or pull request already exists close:duplicate Closed as duplicate dedupe:child Duplicate issue/PR child in dedupe cluster labels Aug 7, 2026
@vincentkoc vincentkoc self-assigned this Aug 7, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Thanks @jackoconner45. The earlier, broader repair at #119930 remains open under exact-head review, and the canonical issue #119929 stays open until that repair lands.

This PR covers the same agent identity-clear path. The earlier PR also carries the Control UI, SDK, identity-file, and Gateway boundaries, so no unique behavior is being dropped here. Closing this narrower PR as a duplicate.

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 close:duplicate Closed as duplicate dedupe:child Duplicate issue/PR child in dedupe cluster duplicate This issue or pull request already exists gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agents.update: empty emoji/avatar silently keeps previous identity values

2 participants