openclaw - 💡(How to fix) Fix infer model run should expose a flag to skip agent-context wrapping for raw provider testing [2 comments, 3 participants]

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…
GitHub stats
openclaw/openclaw#73308Fetched 2026-04-29 06:21:07
View on GitHub
Comments
2
Participants
3
Timeline
3
Reactions
0
Timeline (top)
commented ×2closed ×1

Error Message

Actual: session metadata records inputTokens: 13074, status: running, embedded runtime retries 4× with same runId, every attempt ends in embedded_run_agent_end / error: 'terminated | other side closed', command never returns. Direct POST to the same hailo-ollama endpoint with the same model + same num_ctx returns coherent text in ~1s, confirming the provider itself is healthy — the problem is openclaw's pre-dispatch context inflation.

Fix Action

Fix / Workaround

openclaw infer model run --local --model <provider>/<model> --prompt "..." is documented as "Run a one-shot model turn" and the source path in src/cli/capability-cli.ts:580-680 looks like a thin builder that would dispatch only [{ role: "user", content: <prompt> }]. In practice the embedded runtime it hands off to re-wraps the request with the default agent's full context (bootstrap files, memory chunks, skills, identity profile) before dispatching to the provider.

Actual: session metadata records inputTokens: 13074, status: running, embedded runtime retries 4× with same runId, every attempt ends in embedded_run_agent_end / error: 'terminated | other side closed', command never returns. Direct POST to the same hailo-ollama endpoint with the same model + same num_ctx returns coherent text in ~1s, confirming the provider itself is healthy — the problem is openclaw's pre-dispatch context inflation.

Same behavior with --gateway (where promptMode: "none", modelRun: true is sent in the dispatch payload but doesn't actually skip context loading).

RAW_BUFFERClick to expand / collapse

Problem

openclaw infer model run --local --model <provider>/<model> --prompt "..." is documented as "Run a one-shot model turn" and the source path in src/cli/capability-cli.ts:580-680 looks like a thin builder that would dispatch only [{ role: "user", content: <prompt> }]. In practice the embedded runtime it hands off to re-wraps the request with the default agent's full context (bootstrap files, memory chunks, skills, identity profile) before dispatching to the provider.

This makes the command unusable for testing local provider backends with constrained context windows — the very use case --local looks designed for. On a Hailo-NPU host with a HEF-compiled model (effective context ~2-4K tokens), a 5-word user prompt becomes a ~13K-token request after agent wrapping, overflowing the HEF and surfacing as terminated | other side closed.

Reproduction

Host with:

  • ~/.openclaw/openclaw.json agent default has any non-trivial bootstrap (e.g., AGENTS.md ≈ 10K chars per openclaw doctor).
  • models.providers.ollama.models[*] includes a small-effective-context model. We use qwen2:1.5b served by hailo-ollama on 127.0.0.1:8000.
  • models.providers.ollama.models[<qwen2>].params.num_ctx = 2048 set (working as of 2dba9e6a76 in v2026.4.26).

Run: ```bash openclaw infer model run --local --model ollama/qwen2:1.5b --prompt "Reply: pong" --json ```

Expected: thin model-only call, ~5-10 input tokens, fast response.

Actual: session metadata records inputTokens: 13074, status: running, embedded runtime retries 4× with same runId, every attempt ends in embedded_run_agent_end / error: 'terminated | other side closed', command never returns. Direct POST to the same hailo-ollama endpoint with the same model + same num_ctx returns coherent text in ~1s, confirming the provider itself is healthy — the problem is openclaw's pre-dispatch context inflation.

Same behavior with --gateway (where promptMode: "none", modelRun: true is sent in the dispatch payload but doesn't actually skip context loading).

Suggested fix

Add --skip-agent-context (or --raw) to infer model run:

  • When set, dispatch with literally [{ role: "user", content: <prompt> }] — no bootstrap, no memory, no skills, no identity injection.
  • Useful for: provider conformance testing, debugging provider-specific quirks (context size, tool support, encoding), confirming a provider is reachable on a host without agent-runtime noise interfering with the diagnosis.

--gateway should honor the same flag end-to-end (the promptMode: "none" path already implies this intent; just isn't actually wired through to skip the embedded runtime's context loader).

Environment

  • openclaw 2026.4.26 (be8c246)
  • node 22.22.2
  • Linux 6.12.75-rpi (Raspberry Pi 5, arm64)
  • Local provider: hailo-ollama on 127.0.0.1:8000

Related

2dba9e6a76 (v2026.4.26) added params.num_ctx per-model override which addresses runtime-side context allocation — verified working on this host. The agent-prompt-inflation issue is the remaining half. Conceptually related to closed #70782 ("slim mode to pass --bare").

extent analysis

TL;DR

Add a --skip-agent-context flag to the infer model run command to prevent context inflation and allow for thin model-only calls.

Guidance

  • The issue is caused by the embedded runtime inflating the request with the default agent's full context, exceeding the effective context window of the model.
  • To verify the issue, run the openclaw infer model run command with the --local flag and a small prompt, and observe the increased input tokens and error message.
  • To mitigate the issue, add a --skip-agent-context flag to the command, which would dispatch the request with only the user's prompt and no additional context.
  • The --gateway flag should also be updated to honor the --skip-agent-context flag and skip context loading.

Example

No code snippet is provided as the issue is related to the behavior of the openclaw command and its flags.

Notes

The suggested fix is to add a new flag to the infer model run command, which would require updates to the command's implementation. The issue is specific to the openclaw command and its interaction with the embedded runtime and model providers.

Recommendation

Apply the workaround by adding the --skip-agent-context flag to the infer model run command, as it would allow for thin model-only calls and prevent context inflation. This flag would be useful for provider conformance testing, debugging, and confirming provider reachability without agent-runtime noise.

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 infer model run should expose a flag to skip agent-context wrapping for raw provider testing [2 comments, 3 participants]