Skip to content

[Bug]: chat.inject fails when transcript file is missing (createIfMissing=false) #36170

@See-Cat

Description

@See-Cat

Bug type

Behavior bug (incorrect output/state without crash)

Summary

chat.inject returns:

failed to write transcript: transcript file not found

when the resolved transcriptPath exists in session metadata but the transcript file itself does not exist on disk (ENOENT). Manually creating (touching) the transcript
file makes the error go away immediately.

This breaks transcript persistence and makes chat.history / sessions_history return empty.

Steps to reproduce

  1. Configure OpenClaw with ACP backend acpx and run an ACP oneshot/run session (nonInteractive).
    2. Observe the session entry has a transcriptPath like:
    ~/.openclaw/agents/<agentId>/sessions/<sessionId>.jsonl
    but the file does not exist (ENOENT).
    3. Call gateway RPC chat.inject with params:
    { "sessionKey": "<sessionKey>", "message": "hello" }
    4. Observe error:
    failed to write transcript: transcript file not found
    5. Workaround: touch the transcript file at transcriptPath, then retry chat.inject; it succeeds and messages are persisted.

Expected behavior

If transcriptPath is resolved but the file is missing, chat.inject should create the transcript file (mkdirp + create/touch) and then append the injected message, instead of failing.

Actual behavior

Source inspection (OpenClaw 2026.3.2) shows chat.inject calls the transcript append helper with createIfMissing: false, so a missing transcript file becomes a hard error.

OpenClaw version

2026.3.2

Operating system

macOS arm64

Install method

brew (openclaw-cli) + LaunchAgent gateway

Logs, screenshots, and evidence

File: `src/gateway/server-methods/chat.ts`                                                                                                                                    
                                                                                                                                                                                 
   - `appendAssistantTranscriptMessag e(...)` returns `"transcript file not found"` if `createIfMissing` is false and the transcript file does not exist.                        
   - RPC method `"chat.inject"` calls `appendAssistantTranscriptMessag e` with:                                                                                                  
     `createIfMissing: false`  
 ### Proposed fix                                                                                                                                                              
                                                                                                                                                                                 
   In `chat.inject`, pass `createIfMissing: true` (or ensure transcript file is created at session creation / first write). Missing transcript file should not hard-fail         
 injection.

Impact and severity

  • Affected: ACP oneshot/run sessions where transcript is not pre-created
    • Severity: High (breaks persistence/observability; history APIs unusable)
    • Frequency: 100% when transcript file is missing
    • Consequence: chat history remains empty; tooling depending on transcript breaks

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbug:behaviorIncorrect behavior without a crash

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions