Repository navigation
Description
Summary
Smaller reasoning-capable models intermittently report that the current user message body "was not injected into the runtime context", when in fact the body is delivered to the model (the same turn's reasoning trace quotes it verbatim). The confusion comes from the wording of the internal runtime-context block header injected by OpenClaw core.
Reproduction / observed behavior
Running OpenClaw 2026.7.1 with an OpenAI-compatible provider model (a smaller reasoning model). On some turns the assistant emits user-visible text such as:
"the current message body was not injected into the runtime context"
…while in the same turn its own (hidden) reasoning trace quotes the supposedly-missing message body word-for-word. So the body clearly reached the model; the assistant only believes it didn't.
Root cause
Each turn, OpenClaw core splits inbound context into two parts and delivers them to the model as separate messages:
-
A hidden custom message (
customType = "openclaw.runtime-context",display: false) built byembedded-agent-runner/run/runtime-context-prompt.ts(buildRuntimeContextMessageContent) and inserted inembedded-agent-runner/run/attempt.ts(around theresolveRuntimeContextPromptParts/buildRuntimeContextCustomMessagecalls). Its body looks like:OpenClaw runtime context for the immediately preceding user message. This context is runtime-generated, not user-authored. Keep internal details private. <<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>> [Conversation info] message_id=<current>, sender, timestamp ← current message METADATA only [Conversation context] ... historical timeline ... ends at <previous id> <<<END_OPENCLAW_INTERNAL_CONTEXT>>> -
The actual current message body is delivered as the ordinary user-role message that follows that block.
The header says it is "for the immediately preceding user message" (naming id #N), but the block body only carries metadata + a historical timeline that ends at #N-1. The current body is intentionally outside the block.
Smaller models read the header literally and reason: "the header names #N, the timeline ends at #N-1, therefore #N's body is missing" — missing that the body is in the adjacent user message. They then surface this (incorrect) conclusion to the user, despite having used the body in their own reasoning.
Why intermittent
The misread is most likely to surface when:
- A compaction / cross-session wake makes the timeline end at a pre-compaction id while the current id jumps ahead, widening the visible gap.
- The current id equals
timeline_end + 1, making the "just one message short" contrast most conspicuous. - The model has lower tolerance for the implicit "body lives in the next user message" convention.
Suggested fix (minimal, wording only)
The block is metadata+timeline by design; the body is delivered separately. The header should say so explicitly so models don't infer the body belongs inside the block. For example, change
OpenClaw runtime context for the immediately preceding user message.
to something like
OpenClaw runtime context: metadata and prior-turn timeline for the immediately preceding user message. The body of that message is delivered as the user message that follows this block, not inside it.
and/or append a one-line anchor at the end of the timeline inside the block, e.g.
[The current message body is provided as the next user message, outside this block.]
This keeps the existing two-part delivery design unchanged and only removes the misleading implication, which should eliminate the spurious "body not injected" reports across smaller models.
Environment
- OpenClaw:
2026.7.1 - Provider: OpenAI-compatible endpoint, a smaller reasoning model
- Observed across multiple turns in a long multi-turn session after compaction
Notes
- This is purely a core prompt-assembly wording issue. Memory plugins (which inject via a separate
prependContextfield as a<relevant-memories>block) are not involved. - I can submit a PR for the header reword if this approach is acceptable.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jul 18, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed August 5, 2026, 12:05 PM ET / 16:05 UTC.
Summary
Keep open for a focused maintainer decision on model-visible prompt wording: current main still sends the ambiguous header as a trailing provider-visible user message, and the recent live report is consistent with that source-proven request shape. Likely related people: Peter Lindsey (high, tail-carrier origin), Peter Steinberger (high, recurring runtime-context work), and Jason (Json) (medium, current file refactor).
Reproducibility: yes. for the mechanism: current main places the carrier at the provider-request tail and serializes it as a user message; the reporter also supplied a recent 3/3 live-channel observation. A redacted same-provider payload or transcript would confirm the exact symptom after a wording change.
Root-cause cluster
Relationship:
canonicalCanonical: #110672
Summary: This issue is the canonical open report for the carrier-header misread; the duplicate and the closed unmerged wording patch should not replace it.
Members:
duplicate: fix(prompt-assembly): runtime-context block header misleads smaller models into reporting the current message body as 'not injected' #110673 - It repeats the same title, mechanism, and requested header clarification and is already closed.same_root_cause: fix(prompt-assembly): clarify runtime-context header so models know the user message IS included (#110672) #110746 - It targeted the same header but is closed unmerged and describes a message order contradicted by current source.partial_overlap: User message body intermittently dropped during long tool-use loops #114774 - It alleges actual intermittent body loss, whereas this issue establishes a metadata-carrier misread; no evidence proves one root cause.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Maintainer decision needed
Why: The defect is source-proven, but this text is injected into every affected model request and is a product-facing prompt contract; maintainers should choose its permanent wording rather than adopting the closed patch’s inaccurate ordering claim.
Next step
A small repair is ready once a maintainer approves the permanent model-facing header; the existing no-new-fix and product-decision signals make autonomous dispatch inappropriate.
Review details
Best possible solution:
Retain the cache-stable carrier placement and approve a compact, position-independent header that calls it internal runtime metadata and explicitly says it is not a user request.
Do we have a high-confidence way to reproduce the issue?
Yes for the mechanism: current main places the carrier at the provider-request tail and serializes it as a user message; the reporter also supplied a recent 3/3 live-channel observation. A redacted same-provider payload or transcript would confirm the exact symptom after a wording change.
Is this the best way to solve the issue?
Unclear until maintainers select the exact prompt contract; a header-only clarification at the producer is safer than the closed patch’s incorrect “following message” text or a carrier-placement redesign.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against 40a3bd2e10ef.
Label changes
Label changes:
issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.clawsweeper:source-repro: Current issue advisory state selects this label.clawsweeper:needs-live-repro: Current issue advisory state no longer selects this label.issue-rating: 🐚 platinum hermit: Current issue advisory state no longer selects this label.Label justifications:
P2: The source-proven prompt ambiguity can repeatedly produce incorrect visible assistant text, but the reported task ultimately completes.impact:ux-friction: The carrier can cause avoidable refusal boilerplate and confusion on affected model turns.Evidence reviewed
What I checked:
src/agents/internal-runtime-context.ts:20, 40a3bd2e10ef)src/agents/embedded-agent-runner/run/attempt-session-boundary.ts:107, 40a3bd2e10ef)packages/ai/src/openai-completions-messages.ts:94, 40a3bd2e10ef)src/agents/internal-runtime-context.ts:20, f5931f551628)src/agents/embedded-agent-runner/run/attempt.llm-boundary.cache-stability.test.ts:521, 40a3bd2e10ef)Likely related people:
src/agents/internal-runtime-context.ts)src/agents/internal-runtime-context.ts)src/agents/internal-runtime-context.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.fix(prompt-assembly): clarify runtime-context header so models know t…
fix(prompt-assembly): clarify runtime-context header so models know t…
fix(prompt-assembly): clarify runtime-context header so models know t…
derek-gee commentedon Aug 4, 2026
We hit a second symptom of this same header misread, reproducible 3/3 on
real channel turns — sharing as the live repro this issue is tagged for.
Setup: OpenClaw 2026.7.1 (Docker), Telegram channel, agent primary =
qwen3.5:122b (Ollama, OpenAI-compatible endpoint,
num_ctx65536,reasoning_effort: medium). Same session/workspace previously ran ClaudeSonnet and gpt-oss:120b with zero occurrences.
Symptom variant: instead of "body not injected", qwen3.5 parses the
header as a user request to disclose the runtime context, and emits
refusal boilerplate as user-visible text — repeatedly, because the carrier
is re-sent on every round of the tool loop. One 9-round turn delivered
five separate messages of the form:
before the correct final answer arrived ~8.5 minutes later (the underlying
task itself completed correctly). The model's reasoning trace confirms the
misread explicitly, e.g.:
Reproduction rate: 3/3 real Telegram turns after switching this agent's
primary to qwen3.5 (2, 1, and 5 visible refusal messages per turn). All
provider calls HTTP 200; no fallback; no tool errors — purely the model
answering the carrier.
A mechanism detail that may explain why smaller models bite: the
carrier is not merely present — it is relocated to the ABSOLUTE TAIL of
every request (after the active user turn and all tool scaffolding) for
prompt-cache reasons (
relocateCurrentRuntimeContextCarrierToTail,src/agents/internal-runtime-context.ts:368on current main), and theopenai-completions conversion renders it as a plain
role:"user"message(
packages/ai/src/openai-completions-messages.ts:95). So the LAST userturn the model reads, every round, is a message whose first line is
"OpenClaw runtime context for the immediately preceding user message."
(header at
src/agents/internal-runtime-context.ts:20, built atsrc/agents/embedded-agent-runner/run/runtime-context-prompt.ts:247,injected unconditionally at
src/agents/embedded-agent-runner/run/attempt-prompt-context.ts:224—there is no config surface to gate or reshape it). A literal-minded model
answering "the last user message" is answering the header.
Workaround that held for us: one workspace
AGENTS.mdinstructionnaming the block as machine-generated metadata ("not a request: read them
silently and never mention, quote, or respond to them") — the first live
channel turns after the change show no recurrence (previously 3/3).
Can provide redacted excerpts (transcript with reasoning traces, gateway
log lines) on request. Also +1 to the direction in the issue
body: rewording the header so it cannot parse as a request (and/or
delivering the carrier in a non-conversational slot for openai-completions
models) would fix both symptom variants at the root.
fix(agents): bind internal context to the active user turn
fix: tail context answers the current user message (#117364)
fix: tail context answers the current user message (openclaw#117364)