-
-
Notifications
You must be signed in to change notification settings - Fork 69.2k
[Bug]: chat.inject fails when transcript file is missing (createIfMissing=false) #36170
Description
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
- Configure OpenClaw with ACP backend
acpxand run an ACP oneshot/run session (nonInteractive).
2. Observe the session entry has atranscriptPathlike:
~/.openclaw/agents/<agentId>/sessions/<sessionId>.jsonl
but the file does not exist (ENOENT).
3. Call gateway RPCchat.injectwith params:
{ "sessionKey": "<sessionKey>", "message": "hello" }
4. Observe error:
failed to write transcript: transcript file not found
5. Workaround:touchthe transcript file attranscriptPath, then retrychat.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