Skip to content

fix(agents): pass agentDir to media understanding in ACP dispatch path [AI-assisted]#72832

Merged
steipete merged 3 commits into
openclaw:mainfrom
luyao618:fix/55046-dispatch-acp-media-agentdir
Apr 27, 2026
Merged

fix(agents): pass agentDir to media understanding in ACP dispatch path [AI-assisted]#72832
steipete merged 3 commits into
openclaw:mainfrom
luyao618:fix/55046-dispatch-acp-media-agentdir

Conversation

@luyao618

Copy link
Copy Markdown
Contributor

🤖 AI-assisted (built with Codex via Hermes orchestration). Test level: lightly tested. Prompt summary available on request.

Summary

  • Problem: When a non-visual model is configured with a separate image understanding model, the ACP dispatch path fails to invoke the media understanding pipeline because applyMediaUnderstanding is called without the agentDir parameter. Without agentDir, the pipeline cannot locate agent-specific models.json and auth profiles, so image understanding silently falls back to raw content.
  • Why it matters: Users with multi-agent setups and non-visual models (e.g., MiniMax-M2.7) configured with image understanding models cannot process images through the ACP path — the pipeline silently does nothing.
  • What changed: Added agentDir: resolveAgentDir(params.cfg, acpAgentId) to the applyMediaUnderstanding call in dispatch-acp.ts, aligning it with the non-ACP reply path in get-reply.ts which already passes agentDir correctly.
  • What did NOT change (scope boundary): No changes to the media understanding pipeline itself, no changes to the non-ACP reply path, no changes to auth profile resolution logic.

Change Type (select all)

  • Bug fix

Scope (select all touched areas)

  • Agent loop / reply pipeline

Linked Issue/PR

Root Cause

  • Root cause: dispatch-acp.ts calls applyMediaUnderstanding({ ctx, cfg }) without the optional agentDir parameter. When agentDir is missing, the media understanding pipeline falls back to resolveOpenClawAgentDir() which requires the OPENCLAW_AGENT_DIR environment variable — absent in most setups. Without it, the pipeline cannot find models.json or auth credentials for the configured image understanding model.
  • Missing detection / guardrail: The non-ACP path (get-reply.ts) already passes agentDir correctly (line 250), but the ACP path was not updated to match when media understanding support was added to it.
  • Contributing context: The agentDir parameter is optional in applyMediaUnderstanding's signature, so the omission does not cause a type error — it silently degrades.

Regression Test Plan

  • Coverage level that should have caught this:
    • Unit test
  • Target test or file: src/auto-reply/reply/dispatch-acp.test.ts
  • Scenario the test should lock in: An ACP dispatch turn with inbound media should pass the agent-scoped directory to the media understanding call.
  • Why this is the smallest reliable guardrail: The existing test mocks applyMediaUnderstanding as a pass-through; adding an argument assertion would verify agentDir is forwarded.
  • Existing test that already covers this (if any): N/A — dispatch-acp tests do not currently exercise the media understanding path.
  • If no new test is added, why not: The existing test infrastructure mocks the entire media understanding module; the fix is a 1-line parameter addition that aligns with the already-tested get-reply.ts path. The applyMediaUnderstanding function's internal use of agentDir is covered by src/media-understanding/apply.ts tests.

User-visible / Behavior Changes

  • Image understanding now works correctly for non-visual models in ACP dispatch sessions (e.g., MiniMax-M2.7 with a configured image understanding model). Previously, images were silently passed as raw content without description.

Diagram (if applicable)

N/A

Security Impact (required)

  • New permissions/capabilities? No
  • This fix passes the same agentDir that is already used in the non-ACP path. No new file access, no new permissions — just consistent behavior between the two reply paths.

@greptile-apps

greptile-apps Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds the missing agentDir parameter to the applyMediaUnderstanding call in the ACP dispatch path (dispatch-acp.ts), aligning it with the equivalent call in get-reply.ts that already passes agentDir correctly. The fix is a single-line change plus the required import from ../../agents/agent-scope.js, and it is well-scoped with no functional changes outside the ACP media understanding call.

Confidence Score: 5/5

Safe to merge — minimal, focused change with no risk of regression outside the ACP media understanding path.

The change is a one-line parameter addition to align the ACP path with the existing non-ACP path. The omission was silent (optional parameter), the fix is consistent with how acpAgentId is used elsewhere in the same function (delivery coordinator, etc.), and applyMediaUnderstanding failures are already caught and logged gracefully.

No files require special attention.

Reviews (1): Last reviewed commit: "fix(agents): pass agentDir to media unde..." | Re-trigger Greptile

@martingarramon martingarramon 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.

This brings the ACP dispatch path in line with the non-ACP path in get-reply.ts, where resolveAgentDir(cfg, agentId) is called at line 229 and threaded into applyMediaUnderstanding at line 250. The ACP side was calling applyMediaUnderstanding without agentDir, so agent-scoped filesystem and workspace constraints were silently ignored for ACP sessions. Importing from agent-scope.js matches the existing get-reply.ts import.

One concern not raised in the bot review: with agentDir now passed, can a previously silent path become a NEW failure for ACP agents that have no configured directory? resolveAgentDir returns string | undefined, and applyMediaUnderstanding's agentDir?: string (per get-reply.ts:134) is optional — passing undefined is functionally identical to omitting the parameter. So no new failure mode introduced.

LGTM — closes a real silent omission, no regression risk.

@steipete steipete force-pushed the fix/55046-dispatch-acp-media-agentdir branch 4 times, most recently from ad52f70 to 9cc4dc0 Compare April 27, 2026 20:10
luyao618 and others added 3 commits April 27, 2026 21:12
The ACP dispatch path calls applyMediaUnderstanding without the agentDir
parameter. This prevents the media understanding pipeline from locating
agent-specific models.json and auth profiles, causing image understanding
to fail silently for non-visual models configured with a separate image
understanding model.

The non-ACP reply path (get-reply.ts) already passes agentDir correctly.
This aligns the ACP path with the same behavior.

Closes openclaw#55046

AI-assisted (built with Hermes orchestration).
@steipete steipete force-pushed the fix/55046-dispatch-acp-media-agentdir branch from 9cc4dc0 to 7e2f3fa Compare April 27, 2026 20:12
@steipete steipete merged commit 346d5c2 into openclaw:main Apr 27, 2026
121 of 123 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Media Understanding Pipeline is not working for non-visual models

3 participants