Skip to content

fix(cli): honor agent selection for image descriptions - #147456

Merged
obviyus merged 2 commits into
mainfrom
bugloop/media-cli-agent-selection
Sep 13, 2026
Merged

obviyus merged 2 commits into
mainfrom
bugloop/media-cli-agent-selection

Conversation

@obviyus

@obviyus obviyus commented Sep 13, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Image inference accepts --agent, discards the selected identity, and fails in explicit multi-agent fleets—even when the named agent exists.

Supersedes #145188 by @MertBasar0. Reported in #145119 by @jarvis-stephens-bot.

User Impact

Image description works with the selected agent. Audio and video commands carry the same selected identity and retain their existing successful output behavior.

Why This Change Was Made

The decision which agent owns the operation stays with resolveCapabilityProviderAgentId in src/cli/capability-cli/shared.ts. All four CLI call sites now forward that decision alongside its credential directory. Tests check both values at the runtime boundary. Current audio evaluation order and provider/model output are preserved.

Evidence

With three explicit-owner agents and a synthetic loopback provider, the following commands failed before any HTTP request on main 4394ad538cac. They succeed on 068dc9c759d9:

pnpm openclaw infer image describe --file image.png --prompt describe --agent finance --json
pnpm openclaw infer image describe --file image.png --prompt describe --model stubvision/stub-vision-1 --agent finance --json
pnpm openclaw infer image describe-many --file image.png --file image.png --prompt describe --agent finance --json

Sanitized terminal captures:

Before: exit 1; ok=false; AgentSelectionRequiredError; HTTP requests=0
After describe: exit 0; ok=true; SYNTHETIC_IMAGE_DESCRIPTION; requests=1
After explicit model: exit 0; ok=true; SYNTHETIC_IMAGE_DESCRIPTION; requests=1
After describe-many: exit 0; ok=true; two descriptions; requests=2

The real Gateway passed its health check. These media commands use local transport. Sole-agent image, configured audio transcription, and configured video description succeed before and after; audio/video are consistency controls, not reproduced failures.

The new registered-command assertions fail nine cases on trusted main 21aaac7ad6e7 and pass after the repair. On merge e0665878861f (parents 068dc9c759d9 and main 1692f891b167), all five selected test files pass: 332 tests.

Validation commands and limits
node scripts/run-vitest.mjs run --config test/vitest/vitest.cli.config.ts src/cli/capability-cli.test.ts --testNamePattern 'owner selection'
node --import tsx scripts/ci-run-node-test-shard.mts
pnpm openclaw infer audio transcribe --file audio.wav --agent finance --json
pnpm openclaw infer video describe --file video.mp4 --agent finance --json

The CI test runner selected the full capability CLI, local account-secret, media runtime, settings-storage, and proxy lifecycle test files. CLI/account tests: 259; media runtime: 33; settings: 15; proxy: 25. An inherited color setting first affected the settings numeric-output assertion; disabling forced color passed without source or test changes. The successful owner/runtime suites were not repeated.

Formatting, syntax lint, assertion safety, line limits, and unused-export checks pass. CI run 34784959798 passed at 068dc9c759d99233ed17b668bef97b94ad10ab86, including production and test typechecks.

The original PR's settings failure was repaired upstream in #147029. Its old proxy child-exit failure remains unexplained; both exact tests passed in its matched main-parent CI. The current tests pass, but this does not waive fresh CI or declare the old proxy failure unrelated.

External SDK compatibility: The same external consumer compiled and ran against the shipped 2026.9.4 package and the packaged candidate at 068dc9c759d9 in one isolated container. Directory-only and agentId calls passed for both audio and video: four successful calls per package, with the expected credential directory and loopback-only transport.

Compatibility

Audio/video SDK parameter types gain optional agentId fields. Existing directory-only callers remain valid. There is no new export, config key, schema, migration, protocol, or dependency.

Consumers

The selected agent identity and its credential directory now reach all four media CLI runtime calls. The existing runtime uses that identity for image model and workspace context. Audio and video retain their existing credential-directory behavior.

The optional audio/video agentId fields extend the existing SDK parameter types. Existing directory-only callers remain valid. Browser screenshot description, sticker description, and voice transcription callers are unchanged; this PR does not claim to repair their separate identity-forwarding gaps.

The three image command cases fail before any HTTP request on the recorded main baseline and succeed on the candidate. Configured audio/video and sole-agent image commands pass before and after. Automatic-selection cases were not executed.

The media commands use local transport. The running Gateway is a health control. The 332 passing tests are the selected complete test files on the recorded fresh merge; full CI and typechecking passed in the exact-head run linked above.

No cache or persisted state is added; existing account preparation and request cleanup keep their owners.

MertBasar0 and others added 2 commits September 14, 2026 02:56
Carry the validated agent identity alongside its directory in image description,
audio transcription, and video description calls. Add optional audio and video
runtime parameters and check identity forwarding through registered CLI commands.

Refs #145119

(cherry picked from commit 8dfa5563e6307eac624ca9257cff7685ca5f1196)
@clawsweeper

clawsweeper Bot commented Sep 13, 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 cli CLI command changes size: S maintainer Maintainer-authored PR labels Sep 13, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 13, 2026, 6:13 PM ET / 22:13 UTC (Revision 3).

ClawSweeper review

What this changes

The PR forwards the selected agent identity alongside its credential directory through image, audio, and video inference, adds optional audio/video runtime parameters, and strengthens command-routing assertions.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains a useful, focused fix: current main still drops the selected image agent identity. No actionable correctness or security findings remain, and the supplied terminal evidence demonstrates the repaired behavior. The prior SDK compatibility concern is explicitly addressed in the PR body.

Priority: P2
Reviewed head: 068dc9c759d99233ed17b668bef97b94ad10ab86

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with convincing runtime evidence, meaningful regression assertions, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The supplied terminal captures exercise the actual CLI and media runtime against a loopback provider: all three previously failing image cases reach HTTP and return descriptions after the fix, with successful sole-agent and configured audio/video controls.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The supplied terminal captures exercise the actual CLI and media runtime against a loopback provider: all three previously failing image cases reach HTTP and return descriptions after the fix, with successful sole-agent and configured audio/video controls.
Evidence reviewed 8 items Current-main defect remains: At fetched main, runImageDescribe resolves agentId but passes only agentDir to both image-description paths. The patch adds the missing identity without changing selection policy.
Existing runtime contract explains the failure: runMediaUnderstandingFile already conditionally forwards agentId, and describePreparedImageWithModel does likewise. loadProviderScopedThinkingCatalog falls back to ambient ownership when that identity is absent, explaining the explicit multi-agent failure.
Documented command behavior and release check: The inference documentation promises explicit agent selection for image descriptions. Reading image.ts from v2026.9.4 through GitHub’s contents API confirmed that the released implementation also omits agentId at both calls; no shipped fix was established.
Findings None None.
Security None None.

How this fits together

OpenClaw’s media inference CLI selects an agent and passes media to the shared understanding runtime. That runtime uses the agent’s model and credential context to obtain descriptions or transcripts from providers.

flowchart LR
  A[Media file and CLI options] --> B[Resolve configured agent]
  B --> C[Prepare selected credentials]
  C --> D[Media understanding runtime]
  D --> E[Provider request]
  E --> F[Description or transcript]
Loading

Before merge

  • Resolve merge risk (P1) - The optional audio/video SDK parameters expand a public contract; existing directory-only behavior has source and test support, but third-party plugin combinations were not exercised.
Agent review details

Security

None.

PR surface

Source +6, Tests +35. Total +41 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 4 6 0 +6
Tests 1 53 18 +35
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 59 18 +41

Review metrics

Metric Value Why it matters
Public parameter additions 2 optional agentId fields; 0 new exports or config options The public-contract extension is additive and explicitly discussed in the PR body.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #145119
Summary: This PR is a candidate repair for the established image agent-forwarding issue and carries the earlier contributor patch.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept the documented additive SDK change (recommended)
    Retain the optional fields with the documented directory-only behavior and existing compatibility coverage; no concrete breaking change was found.

Technical review

Best possible solution:

Preserve the selected identity and credential directory together through the existing media runtime while retaining directory-only SDK compatibility.

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

Yes. Current source establishes the missing identity forwarding, and the supplied before/after CLI traces demonstrate the failure with three explicit-owner agents; this read-only review did not independently execute it.

Is this the best way to solve the issue?

Yes. Forwarding the already-resolved identity repairs the existing owner boundary without duplicating selection logic, changing defaults, or requiring migration.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This repairs a concrete image-inference failure limited to explicit multi-agent configurations.
  • merge-risk: 🚨 compatibility: Two SDK-reachable parameter types gain optional fields, making preservation of existing directory-only callers relevant to merge review.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The supplied terminal captures exercise the actual CLI and media runtime against a loopback provider: all three previously failing image cases reach HTTP and return descriptions after the fix, with successful sole-agent and configured audio/video controls.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied terminal captures exercise the actual CLI and media runtime against a loopback provider: all three previously failing image cases reach HTTP and return descriptions after the fix, with successful sole-agent and configured audio/video controls.

Evidence

What I checked:

  • Current-main defect remains: At fetched main, runImageDescribe resolves agentId but passes only agentDir to both image-description paths. The patch adds the missing identity without changing selection policy. (src/cli/capability-cli/image.ts:180, 04f20b56bf4d)
  • Existing runtime contract explains the failure: runMediaUnderstandingFile already conditionally forwards agentId, and describePreparedImageWithModel does likewise. loadProviderScopedThinkingCatalog falls back to ambient ownership when that identity is absent, explaining the explicit multi-agent failure. (src/media-understanding/runtime.ts:225, 068dc9c759d9)
  • Documented command behavior and release check: The inference documentation promises explicit agent selection for image descriptions. Reading image.ts from v2026.9.4 through GitHub’s contents API confirmed that the released implementation also omits agentId at both calls; no shipped fix was established. Public docs: docs/cli/infer.md. (docs/cli/infer.md:105, 068dc9c759d9)
  • Real CLI proof: The complete supplied PR body records three-agent loopback-provider runs on candidate 068dc9c: default description and explicit-model description each return success with one HTTP request, and describe-many returns two descriptions with two requests. The baseline fails before HTTP. Sole-agent image and configured audio/video succeed before and after. Gateway health is correctly described as a control, not proof of these local commands. (068dc9c759d9)
  • SDK compatibility and re-review continuity: The two new fields are optional on existing SDK-reachable parameter types. Runtime spreads already accept the identity, and unchanged runtime tests exercise directory-only audio/video callers. The current body explicitly discusses this public-contract extension. Previous completed reviews retained no findings or published rank-up moves; their third-party coverage warning does not establish a new defect. (src/media-understanding/runtime-types.ts:114, 068dc9c759d9)
  • Regression assertions: The changed tables invoke registered commands and inspect both identity and directory at the runtime boundary, including parent-option inheritance and explicit-model image description. The supplied proof reports nine failing cases before repair and passing candidate coverage; this review did not execute tests. (src/cli/capability-cli.test.ts:2264, 068dc9c759d9)

Likely related people:

  • omarshahine: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • masatohoshino: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-13T21:46:43.199Z sha 068dc9c :: blocked before merge. :: none
  • reviewed 2026-09-13T21:54:20.918Z sha 068dc9c :: blocked before merge. :: none

@obviyus

obviyus commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-admin-merge
pr: 147456
head: 068dc9c
scope: owner-review

@obviyus
obviyus marked this pull request as ready for review September 13, 2026 21:49
@obviyus
obviyus merged commit 911d142 into main Sep 13, 2026
273 checks passed
@obviyus
obviyus deleted the bugloop/media-cli-agent-selection branch September 13, 2026 22:51
@obviyus

obviyus commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @MertBasar0!

Proof: In an explicit multi-agent fleet, all three image description commands now succeed with the selected agent and reach the provider. Sole-agent image, audio, and video controls keep passing.

  • Bug: Image commands rejected a valid --agent selection before sending a request.
  • Fix: The media CLI forwards the selected identity with its credential directory.
Before After
Valid agent selection fails before HTTP Selected agent produces the image description

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
## What Problem This Solves

Image inference accepts `--agent`, discards the selected identity, and fails in explicit multi-agent fleets—even when the named agent exists.

Supersedes openclaw#145188 by @MertBasar0. Reported in openclaw#145119 by @jarvis-stephens-bot.

## User Impact

Image description works with the selected agent. Audio and video commands carry the same selected identity and retain their existing successful output behavior.

## Why This Change Was Made

The decision which agent owns the operation stays with `resolveCapabilityProviderAgentId` in `src/cli/capability-cli/shared.ts`. All four CLI call sites now forward that decision alongside its credential directory. Tests check both values at the runtime boundary. Current audio evaluation order and provider/model output are preserved.

## Evidence

With three explicit-owner agents and a synthetic loopback provider, the following commands failed before any HTTP request on main `bccb84ab286d`. They succeed on `068dc9c759d9`:

```sh
pnpm openclaw infer image describe --file image.png --prompt describe --agent finance --json
pnpm openclaw infer image describe --file image.png --prompt describe --model stubvision/stub-vision-1 --agent finance --json
pnpm openclaw infer image describe-many --file image.png --file image.png --prompt describe --agent finance --json
```

Sanitized terminal captures:

```text
Before: exit 1; ok=false; AgentSelectionRequiredError; HTTP requests=0
After describe: exit 0; ok=true; SYNTHETIC_IMAGE_DESCRIPTION; requests=1
After explicit model: exit 0; ok=true; SYNTHETIC_IMAGE_DESCRIPTION; requests=1
After describe-many: exit 0; ok=true; two descriptions; requests=2
```

The real Gateway passed its health check. These media commands use local transport. Sole-agent image, configured audio transcription, and configured video description succeed before and after; audio/video are consistency controls, not reproduced failures.

The new registered-command assertions fail nine cases on trusted main `d8799ec248a5` and pass after the repair. On merge `e0665878861f` (parents `068dc9c759d9` and main `3642fc8281b9`), all five selected test files pass: **332 tests**.

<details>
<summary>Validation commands and limits</summary>

```sh
node scripts/run-vitest.mjs run --config test/vitest/vitest.cli.config.ts src/cli/capability-cli.test.ts --testNamePattern 'owner selection'
node --import tsx scripts/ci-run-node-test-shard.mts
pnpm openclaw infer audio transcribe --file audio.wav --agent finance --json
pnpm openclaw infer video describe --file video.mp4 --agent finance --json
```

The CI test runner selected the full capability CLI, local account-secret, media runtime, settings-storage, and proxy lifecycle test files. CLI/account tests: 259; media runtime: 33; settings: 15; proxy: 25. An inherited color setting first affected the settings numeric-output assertion; disabling forced color passed without source or test changes. The successful owner/runtime suites were not repeated.

Formatting, syntax lint, assertion safety, line limits, and unused-export checks pass. [CI run 34784959798](https://github.com/openclaw/openclaw/actions/runs/34784959798) passed at `068dc9c759d99233ed17b668bef97b94ad10ab86`, including production and test typechecks.

The original PR's settings failure was repaired upstream in openclaw#147029. Its old proxy child-exit failure remains unexplained; both exact tests passed in its matched main-parent CI. The current tests pass, but this does not waive fresh CI or declare the old proxy failure unrelated.

</details>

**External SDK compatibility:** The same external consumer compiled and ran against the shipped 2026.9.4 package and the packaged candidate at `068dc9c759d9` in one isolated container. Directory-only and `agentId` calls passed for both audio and video: four successful calls per package, with the expected credential directory and loopback-only transport.

## Compatibility

Audio/video SDK parameter types gain optional `agentId` fields. Existing directory-only callers remain valid. There is no new export, config key, schema, migration, protocol, or dependency.

## Consumers

The selected agent identity and its credential directory now reach all four media CLI runtime calls. The existing runtime uses that identity for image model and workspace context. Audio and video retain their existing credential-directory behavior.

The optional audio/video `agentId` fields extend the existing SDK parameter types. Existing directory-only callers remain valid. Browser screenshot description, sticker description, and voice transcription callers are unchanged; this PR does not claim to repair their separate identity-forwarding gaps.

The three image command cases fail before any HTTP request on the recorded main baseline and succeed on the candidate. Configured audio/video and sole-agent image commands pass before and after. Automatic-selection cases were not executed.

The media commands use local transport. The running Gateway is a health control. The 332 passing tests are the selected complete test files on the recorded fresh merge; full CI and typechecking passed in the exact-head run linked above.

No cache or persisted state is added; existing account preparation and request cleanup keep their owners.

Co-authored-by: MertBasar0 <[email protected]>
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 maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. 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