Skip to content

Control UI: Personal card avatar 401 due to inconsistent avatar resolution between agents.list and agent.identity.get #97602

Closed

Description

@mtuwei

Control UI: Personal card avatar 401 due to inconsistent avatar resolution between agents.list and agent.identity.get

Summary

The Personal card in Control UI shows a broken avatar image because agent.identity.get returns /avatar/<agentId> (a path requiring Bearer auth), while agents.list correctly resolves workspace-relative avatars to base64 data URIs. Since <img> tags cannot carry Authorization headers, the Personal card always gets 401.

Environment

Root Cause

Two RPC handlers resolve agent avatars differently:

agents.list RPC — works correctly

File: dist/session-utils-B4hOl7Zv.js:626-640

listAgentsForGateway() calls resolveIdentityAvatarUrl(cfg, agentId, avatar) which:

  1. Detects workspace-relative paths (e.g., avatar/photo.jpg)
  2. Reads the file from disk
  3. Encodes it as data:image/jpeg;base64,...
  4. Returns the data URI as identity.avatarUrl

The chat page reads identity.avatarUrl from the agents.list response → avatar displays correctly.

agent.identity.get RPC — broken

File: dist/agent-CnYmTiHt.js:2096-2100

resolveAssistantAvatarUrl() converts the configured avatar path to /avatar/<agentId> — a server endpoint that requires Bearer token authentication.

The Personal card uses this value in <img src="/avatar/main">. Since <img> tags cannot send Authorization headers, the request fails with 401 Unauthorized.

Frontend behavior

File: dist/control-ui/assets/index-BEWaPr0D.js:818

function xN(e) {
  return to(e.assistantAvatarUrl, {
    identity: {
      avatar: e.assistantAvatar ?? void 0,
      avatarUrl: e.assistantAvatarUrl ?? void 0
    }
  })
}
  • Chat page: uses assistantAvatarUrl (data URI from agents.list) → ✅ works
  • Personal card: uses assistantAvatar (/avatar/main from agent.identity.get) → ❌ 401

Expected Behavior

agent.identity.get should resolve workspace-relative avatars to base64 data URIs the same way agents.list does (via resolveIdentityAvatarUrl), so the Personal card receives a data URI instead of an auth-gated URL path.

Alternatively, the /avatar/<agentId> endpoint could support cookie/session-based authentication so <img> tags can load it without headers.

Steps to Reproduce

  1. Configure an agent with identity.avatar = "avatar/photo.jpg" (workspace-relative path)
  2. Open Control UI, observe chat page — avatar displays correctly (data URI)
  3. Navigate to Personal/Identity card — avatar shows broken image (401 on /avatar/<agentId>)

Suggested Fix

Align agent.identity.get's avatar resolution with agents.list by using resolveIdentityAvatarUrl() instead of resolveAssistantAvatarUrl() when the avatar is a workspace-relative path.

Activity

  1. clawsweeper commented on Jun 29, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 28, 2026, 8:49 PM ET / 00:49 UTC.

    Summary
    Keep open: current main and v2026.6.10 still route local assistant identity avatars from agent.identity.get through an auth-gated /avatar/<agentId> URL while the agents.list path can inline workspace avatars, so the reported Personal card 401 remains actionable.

    Reproducibility: yes. by source inspection: configure a workspace-relative agent avatar, then agent.identity.get returns /avatar/<agentId> while authenticated avatar HTTP requests are required by the gateway. The same avatar source is inlined as a data URI by agents.list.

    Next step
    This is a narrow, source-reproducible Control UI/Gateway bug with clear implementation and regression-test targets.

    Review details

    Best possible solution:

    Share or extract the existing workspace-safe avatar data-URI resolution so agent.identity.get and agents.list agree for local workspace avatars, without weakening /avatar/<agentId> auth or adding new config.

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

    Yes by source inspection: configure a workspace-relative agent avatar, then agent.identity.get returns /avatar/<agentId> while authenticated avatar HTTP requests are required by the gateway. The same avatar source is inlined as a data URI by agents.list.

    Is this the best way to solve the issue?

    Yes, the narrowest maintainable fix is to align the identity RPC with the existing workspace-safe data-URI resolver. Changing /avatar/<agentId> to cookie/session auth would be broader and security-sensitive.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • No live browser session was run in this read-only review, so the visible broken-image symptom is source-proven rather than visually reproduced.

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

    Label changes

    Label changes:

    • add P2: The report describes a normal-priority Control UI rendering bug with limited blast radius and clear likely files.
    • add impact:other: The concrete impact is a broken Control UI Personal/Identity card avatar preview, which is maintainer-visible UI behavior outside the specific owned impact taxonomy.
    • add maturity:stable: The issue affects the M4 Stable gateway-runtime hosted web surface and Gateway RPC/API behavior.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
    • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

    Label justifications:

    • P2: The report describes a normal-priority Control UI rendering bug with limited blast radius and clear likely files.
    • impact:other: The concrete impact is a broken Control UI Personal/Identity card avatar preview, which is maintainer-visible UI behavior outside the specific owned impact taxonomy.
    • maturity:stable: The issue affects the M4 Stable gateway-runtime hosted web surface and Gateway RPC/API behavior.
    Evidence reviewed

    Acceptance criteria:

    • node scripts/run-vitest.mjs src/gateway/server-methods/agent.test.ts
    • node scripts/run-vitest.mjs src/gateway/session-utils.test.ts
    • node scripts/run-vitest.mjs ui/src/ui/views/config-quick.test.ts ui/src/ui/app-render.assistant-avatar.test.ts

    What I checked:

    • Current identity RPC still returns the avatar route for local paths: agent.identity.get resolves the assistant identity, passes identity.avatar through resolveAssistantAvatarUrl, and returns the resulting avatar value to the UI. (src/gateway/server-methods/agent.ts:2851, 87db23e5432b)
    • Shared Control UI resolver maps path-like avatars to /avatar/<agentId>: For local filesystem-looking avatar values, resolveAssistantAvatarUrl builds the Control UI avatar route instead of a data URI. (src/gateway/control-ui-shared.ts:67, 87db23e5432b)
    • Avatar route is protected by Control UI read auth: handleControlUiAvatarRequest authorizes read requests before serving avatar bytes; the existing HTTP test covers a 401 for /avatar/main without a valid token when auth is enabled. (src/gateway/control-ui.ts:700, 87db23e5432b)
    • Agent list path has separate data-URI avatar projection: listAgentsForGateway uses resolveIdentityAvatarUrl, which bounds the workspace path, reads the file, and returns data:<mime>;base64,... as identity.avatarUrl. (src/gateway/session-utils.ts:167, 87db23e5432b)
    • Quick Settings Personal card renders the supplied avatar URL directly: The assistant preview asks resolveChatAvatarRenderUrl for props.assistantAvatarUrl, with props.assistantAvatar only as fallback identity data, so an auth-gated route can become an <img src> URL. (ui/src/ui/views/config-quick.ts:191, 87db23e5432b)
    • Latest release shows the same identity RPC behavior: Tag v2026.6.10 still has agent.identity.get calling resolveAssistantAvatarUrl and returning avatarValue, so the shipped release named by the reporter is affected rather than already fixed. (src/gateway/server-methods/agent.ts:2898, aa69b12d0086)

    Likely related people:

    How this review workflow works
    • 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.
  2. added
    P2
    impact:other
    maturity:stable
    no-stale
    issue-rating: 🦞 diamond lobster
    clawsweeper:source-repro
    clawsweeper:queueable-fix
    clawsweeper:fix-shape-clear
    on Jun 29, 2026
  3. steipete commented on Jul 10, 2026

    @steipete
    Contributor

    Resolved on main: #102892 fixed the workspace-relative Personal-card projection, and #103657 hardened the final implementation at 505f8ae6.

    Exact-head CI passed. A real token-authenticated Gateway + Chromium run loaded the Control UI at /openclaw, rendered the configured inline avatar, and observed zero /avatar/ retries, zero 401s, and zero browser errors.

  4. locked as resolved and limited conversation to collaborators on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2clawsweeper:fix-shape-clearclawsweeper:queueable-fixclawsweeper:source-reproimpact:otherissue-rating: 🦞 diamond lobstermaturity:stableno-stale

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions