openclaw - 💡(How to fix) Fix [Bug]: tokenjuice - main Codex bash results are not compacted [2 pull requests]

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…

TokenJuice is enabled and loaded, but a real main agent run using the Codex runtime receives raw bash output because the persisted tool result lacks exec-style details.

Error Message

TokenJuice plugin state:

plugins.entries.tokenjuice.enabled: true openclaw plugins inspect tokenjuice: Status: loaded

Real run metadata:

session key: agent:main:tokenjuice-confirm-main-20260531 session id: 229393dc-bb43-4706-98d0-1fce9cdbd820 toolSummary.calls: 1 toolSummary.tools: ["bash"]

Observed stored tool result:

role: toolResult toolName: bash isError: false content[0].type: toolResult content[0].content: On branch main... details: absent

Synthetic middleware probes compacted correctly when the same output was supplied with OpenClaw-style exec details:

details.status: "completed" details.exitCode: 0 details.aggregated: raw output details.cwd: /home/user/openclaw/src details.tokenjuice.compacted: true details.tokenjuice.reducer: git/status

Root Cause

TokenJuice is enabled and loaded, but a real main agent run using the Codex runtime receives raw bash output because the persisted tool result lacks exec-style details.

Fix Action

Fixed

Code Example

openclaw config set plugins.entries.tokenjuice.enabled true

---

openclaw plugins inspect tokenjuice

---

openclaw agent \
     --agent main \
     --session-key agent:main:tokenjuice-confirm-main-20260531 \
     --message 'TokenJuice confirmation test. Do not modify files. Use the exec tool exactly once to run: git status. Use workdir /home/user/openclaw/src. Then reply with whether the exec tool result you received was compacted by TokenJuice, including any visible marker such as [tokenjuice compacted bash output] or tokenjuice metadata if present.' \
     --json \
     --timeout 300

---

[tokenjuice compacted bash output]

---

Not compacted by TokenJuice.

---

toolName: "bash"
content[0].type: "toolResult"
content[0].content: raw git status text
content[0].text: raw git status text
details: absent

---

details.status
details.exitCode
details.aggregated
details.cwd
details.tokenjuice

---

agentHarnessId: codex
provider: openai
model: gpt-5.5
agentRuntime.id: codex
agentRuntime.source: implicit

---

TokenJuice plugin state:


plugins.entries.tokenjuice.enabled: true
openclaw plugins inspect tokenjuice: Status: loaded


Real run metadata:


session key: agent:main:tokenjuice-confirm-main-20260531
session id: 229393dc-bb43-4706-98d0-1fce9cdbd820
toolSummary.calls: 1
toolSummary.tools: ["bash"]


Observed stored tool result:


role: toolResult
toolName: bash
isError: false
content[0].type: toolResult
content[0].content: On branch main...
details: absent


Synthetic middleware probes compacted correctly when the same output was supplied with OpenClaw-style exec details:


details.status: "completed"
details.exitCode: 0
details.aggregated: raw output
details.cwd: /home/user/openclaw/src
details.tokenjuice.compacted: true
details.tokenjuice.reducer: git/status
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

TokenJuice is enabled and loaded, but a real main agent run using the Codex runtime receives raw bash output because the persisted tool result lacks exec-style details.

Steps to reproduce

  1. Enable TokenJuice:

    openclaw config set plugins.entries.tokenjuice.enabled true
  2. Confirm it is loaded:

    openclaw plugins inspect tokenjuice
  3. Run a real main agent confirmation turn:

    openclaw agent \
      --agent main \
      --session-key agent:main:tokenjuice-confirm-main-20260531 \
      --message 'TokenJuice confirmation test. Do not modify files. Use the exec tool exactly once to run: git status. Use workdir /home/user/openclaw/src. Then reply with whether the exec tool result you received was compacted by TokenJuice, including any visible marker such as [tokenjuice compacted bash output] or tokenjuice metadata if present.' \
      --json \
      --timeout 300
  4. Inspect the stored session JSONL for the resulting tool result.

Expected behavior

The TokenJuice docs say the plugin applies to OpenClaw embedded runs and OpenClaw dynamic tools in the Codex app-server harness.

For an eligible bash/exec result such as git status, the tool result should be compacted before it is fed back to the model, with visible evidence such as:

[tokenjuice compacted bash output]

and/or details.tokenjuice.

Docs reference: https://docs.openclaw.ai/tools/tokenjuice

Actual behavior

The real main agent run used one bash tool call and received raw git status output.

The assistant replied:

Not compacted by TokenJuice.

The stored session JSONL tool result had this observed shape:

toolName: "bash"
content[0].type: "toolResult"
content[0].content: raw git status text
content[0].text: raw git status text
details: absent

The result did not include:

details.status
details.exitCode
details.aggregated
details.cwd
details.tokenjuice

OpenClaw version

2026.5.30 (5c5711f)

Operating system

linux 7.0.10-arch1-1 x64

Install method

pnpm dev / source checkout

Model

gpt-5.5

Provider / routing chain

OpenClaw main agent -> implicit Codex agent runtime -> OpenAI provider -> gpt-5.5

Additional provider/model setup details

OpenClaw main agent -> implicit Codex agent runtime -> OpenAI provider -> gpt-5.5

The session metadata reported:

agentHarnessId: codex
provider: openai
model: gpt-5.5
agentRuntime.id: codex
agentRuntime.source: implicit

Logs, screenshots, and evidence

TokenJuice plugin state:


plugins.entries.tokenjuice.enabled: true
openclaw plugins inspect tokenjuice: Status: loaded


Real run metadata:


session key: agent:main:tokenjuice-confirm-main-20260531
session id: 229393dc-bb43-4706-98d0-1fce9cdbd820
toolSummary.calls: 1
toolSummary.tools: ["bash"]


Observed stored tool result:


role: toolResult
toolName: bash
isError: false
content[0].type: toolResult
content[0].content: On branch main...
details: absent


Synthetic middleware probes compacted correctly when the same output was supplied with OpenClaw-style exec details:


details.status: "completed"
details.exitCode: 0
details.aggregated: raw output
details.cwd: /home/user/openclaw/src
details.tokenjuice.compacted: true
details.tokenjuice.reducer: git/status

Impact and severity

Affected users/systems/channels: observed on the main agent using the implicit Codex runtime with the TokenJuice plugin enabled.

Severity: blocks the documented TokenJuice plugin behavior for real Codex/main bash results.

Frequency: reproducible in the observed confirmation run and in replay of the persisted live tool-result shape.

Consequence: noisy shell output is fed back to the model un-compacted, increasing context usage and preventing TokenJuice from providing its advertised reduction on this path.

Additional information

The likely integration gap is that the real Codex/main native bash result does not satisfy the TokenJuice OpenClaw adapter gate. The adapter compacts exec/bash only when details.status is "completed" or "failed".

Possible fix direction:

  • Normalize Codex/native bash results before tool-result middleware runs by filling missing exec-like details where possible:
    • status
    • exitCode
    • aggregated
    • cwd
  • Also consider making the TokenJuice OpenClaw adapter defensively handle exec-like textual content when details are missing, using isError as a fallback status signal.

Last known good version: NOT_ENOUGH_INFO First known bad version: 2026.5.30 (5c5711f)

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…

FAQ

Expected behavior

The TokenJuice docs say the plugin applies to OpenClaw embedded runs and OpenClaw dynamic tools in the Codex app-server harness.

For an eligible bash/exec result such as git status, the tool result should be compacted before it is fed back to the model, with visible evidence such as:

[tokenjuice compacted bash output]

and/or details.tokenjuice.

Docs reference: https://docs.openclaw.ai/tools/tokenjuice

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]: tokenjuice - main Codex bash results are not compacted [2 pull requests]