openclaw - 💡(How to fix) Fix [Bug]: image_generate safety rejection stalls tool call and session recovery carries phantom file path

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

When openai/gpt-image-2 via Codex OAuth rejects a prompt for safety_violations=[sexual], the image_generate tool call stalls rather than immediately returning an error. After stall detection and session recovery, the agent context retains the phantom planned filename — which was never written to disk — and attempts to send it on the next turn, producing LocalMediaAccessError: Local media file not found.

Error Message

[image-generation] candidate failed: openai/gpt-image-2: Your request was rejected by the safety system. If you believe this is an error, contact us at help.openai.com and include the request ID 4a0fab57-9ec5-467f-8102-d7390ce8824d. safety_violations=[sexual]. [diagnostic] stalled session: reason=blocked_tool_call classification=blocked_tool_call activeWorkKind=tool_call lastProgress=tool:image_generate:started lastProgressAge=122s activeTool=image_generate recovery=none [tools] message failed: LocalMediaAccessError: Local media file not found: /.../.openclaw/media/tool-image-generation/nero_gen_00006---5273c853-d11e-4527-853b-2853e87d1783.jpg

Root Cause

  1. Agent issues image_generate with a prompt that triggers OpenAI safety moderation
  2. Gateway logs: [image-generation] candidate failed: openai/gpt-image-2: Your request was rejected by the safety system. safety_violations=[sexual]
  3. Tool call does not return an error; session enters stall state: [diagnostic] stalled session: reason=blocked_tool_call activeWorkKind=tool_call lastProgress=tool:image_generate:started activeToolAge=122s recovery=none
  4. Session eventually recovers (next message, gateway restart, etc.)
  5. Agent attempts to deliver nero_gen_NNNNN---<uuid>.jpg — a filename that was planned but never created because the generation was rejected
  6. [tools] message failed: LocalMediaAccessError: Local media file not found: .../tool-image-generation/nero_gen_00006---<uuid>.jpg

Code Example

[image-generation] candidate failed: openai/gpt-image-2: Your request was rejected by the safety system. If you believe this is an error, contact us at help.openai.com and include the request ID 4a0fab57-9ec5-467f-8102-d7390ce8824d. safety_violations=[sexual].
[diagnostic] stalled session: reason=blocked_tool_call classification=blocked_tool_call activeWorkKind=tool_call lastProgress=tool:image_generate:started lastProgressAge=122s activeTool=image_generate recovery=none
[tools] message failed: LocalMediaAccessError: Local media file not found: /.../.openclaw/media/tool-image-generation/nero_gen_00006---5273c853-d11e-4527-853b-2853e87d1783.jpg
RAW_BUFFERClick to expand / collapse

Summary

When openai/gpt-image-2 via Codex OAuth rejects a prompt for safety_violations=[sexual], the image_generate tool call stalls rather than immediately returning an error. After stall detection and session recovery, the agent context retains the phantom planned filename — which was never written to disk — and attempts to send it on the next turn, producing LocalMediaAccessError: Local media file not found.

Steps to Reproduce

  1. Agent issues image_generate with a prompt that triggers OpenAI safety moderation
  2. Gateway logs: [image-generation] candidate failed: openai/gpt-image-2: Your request was rejected by the safety system. safety_violations=[sexual]
  3. Tool call does not return an error; session enters stall state: [diagnostic] stalled session: reason=blocked_tool_call activeWorkKind=tool_call lastProgress=tool:image_generate:started activeToolAge=122s recovery=none
  4. Session eventually recovers (next message, gateway restart, etc.)
  5. Agent attempts to deliver nero_gen_NNNNN---<uuid>.jpg — a filename that was planned but never created because the generation was rejected
  6. [tools] message failed: LocalMediaAccessError: Local media file not found: .../tool-image-generation/nero_gen_00006---<uuid>.jpg

Log Evidence

[image-generation] candidate failed: openai/gpt-image-2: Your request was rejected by the safety system. If you believe this is an error, contact us at help.openai.com and include the request ID 4a0fab57-9ec5-467f-8102-d7390ce8824d. safety_violations=[sexual].
[diagnostic] stalled session: reason=blocked_tool_call classification=blocked_tool_call activeWorkKind=tool_call lastProgress=tool:image_generate:started lastProgressAge=122s activeTool=image_generate recovery=none
[tools] message failed: LocalMediaAccessError: Local media file not found: /.../.openclaw/media/tool-image-generation/nero_gen_00006---5273c853-d11e-4527-853b-2853e87d1783.jpg

Note on the Safety Rejection

The prompt that triggered safety_violations=[sexual] was an anime-style character self-portrait (gold hair, green eyes, no explicit content — equivalent to a standard visual novel character illustration). This appears to be a false positive from the OpenAI image safety classifier. The false positive compounds the main bug: the rejection itself should have been a non-issue, but because the tool stall + dirty-context recovery are not handled, even a spurious rejection cascades into a persistent LocalMediaAccessError on the next turn.

Expected Behavior

  • Safety rejection should immediately surface as a tool error returned to the agent, not leave the tool call hanging
  • The planned file path should not be committed to session context until the file is confirmed written to disk
  • On session recovery, any in-flight image_generate tool calls that never completed should be marked as failed, not replayed with stale state

Environment

  • openclaw: 2026.5.7 (reproduced); upgraded to 2026.5.12 to check regression
  • Transport: openai-codex OAuth / codex-responses
  • Channel: Telegram
  • Related: #69310 (surfacing dropped media), #61065 (MEDIA: path in tool content)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug]: image_generate safety rejection stalls tool call and session recovery carries phantom file path