Skip to content

refactor(agents): exec records its output file in the shared details.spill shape - #206984

Merged
obviyus merged 1 commit into
mainfrom
core/exec-spill-shape
Nov 27, 2026
Merged

obviyus merged 1 commit into
mainfrom
core/exec-spill-shape

Conversation

@obviyus

@obviyus obviyus commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

A tool result can point to a file holding its full output. Two shapes record that pointer:

So every reader handles both shapes:

  • getToolResultSpillDetails (history elision and the bound's producer-spill reuse) falls back to the flat fields. It also reads a spilledChars field that nothing writes.
  • The persisted-details allowlists keep both shapes (6 extra keys).
  • The tokenjuice plugin checks exec's flat field to leave spilled results alone.

Fix

Exec records details.spill { path, truncated? }, the one shape. Exec has bytes, not chars, so it does not set chars. The flat fields and every reader of them are removed:

  • the flat fallback, and the never-written spilledChars, in getToolResultSpillDetails;
  • fullOutputPath, spilledChars and spillTruncated in both persistence allowlists;
  • tokenjuice now checks details.spill.

Accepted edge case: no migration. Exec results recorded before this change keep their text footer (Full output: <path>), but history elision no longer finds their pointer in details. The owner approved this. Spill files live in the OS temp directory anyway, so old pointers rarely outlive the session.

Not touched: fullOutputPath on the session BashResult/BashToolDetails types and the agent-core bash-execution message. Those are a different, extension-facing contract, and exec never writes them.

User impact

None visible. The exec result text is unchanged. Model-visible behavior is the same: elision and the bound reuse exec's file as before, through the shared shape.

Evidence

  • session-tool-result-guard.test.ts: an exec output file cut at its limit records spill: { path, truncated: true }.
  • tool-result-truncation.test.ts: history elision with an exec-shaped spill keeps its pointer.
  • runtime.integration.test.ts (tokenjuice): a spilled exec result is left to the host.
  • tool-result-bounds.test.ts (owner, unchanged) and session-tool-result-guard.tool-result-persist-hook.test.ts (fallback keeps spill) still pass.
  • bash-tools.exec-approval-output.test.ts: a real exec spill path, read through workspace-only read (fix(agents): read cannot open the full output of a large tool result under workspace-only read #206972), comes from details.spill.path.

@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling extensions: tokenjuice Changes to the bundled tokenjuice extension size: S labels Nov 27, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. labels Nov 27, 2026
@obviyus

obviyus commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator Author

Rejected review findings:

  • [P2] Preserve spill recovery for previously recorded session results (tool-result-truncation.ts:528-530): rejected. Old exec results lose their details pointer when history elision cuts them. The owner approved this before the change, with no migration and no compatibility reader. The pointer only matters while its file exists. Spill files live in the OS temp directory with OS cleanup, so pointers in old transcripts are often stale already. Keeping a reader for the flat fields would keep the two-shape contract this PR removes. Only results recorded before this change are affected, and only under aggregate pressure. The original result text still carries its Full output: <path> footer until elision replaces it.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR moves exec output-file metadata into details.spill and updates persistence, history elision, and Tokenjuice to use that shape.

Example: An exec output file at /tmp/openclaw-exec-1.log reaches its size limit.

  • Before: Metadata contains fullOutputPath and spillTruncated: true.
  • After: Metadata contains spill: { path: "/tmp/openclaw-exec-1.log", truncated: true }; the displayed output text stays unchanged.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is focused with no definite introduced defect found, but required persisted-data upgrade proof is absent and typecheck remains unresolved.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Agents need recoverable large command output to survive result bounding, persistence, and history elision.
Reason: The maintainer-authored direction removes duplicate metadata handling without adding an owner, option, or parallel execution path.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this maintainer-authored PR makes a focused consolidation, and inspection found no definite introduced code defect.

Reviewed head: 742a229d14415f161f3df687b9afee239d62cce9

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Agent review details

How this fits together

Exec produces command results and spill-file pointers; result bounding, transcript persistence, history projection, and Tokenjuice consume that metadata.

flowchart LR
  A[Exec process] --> B[Foreground result]
  B --> C[Tokenjuice middleware]
  C --> D[Record-time result bound]
  D --> E[Transcript persistence]
  E --> F[History projection]
  F --> G[Model context]
Loading

Technical review

Best possible solution:

Keep one nested spill representation across exec production, bounding, persistence, elision, and Tokenjuice, preserving the explicitly accepted historical-session tradeoff.

Do we have a high-confidence way to reproduce the issue?

This is a representation refactor; source inspection confirms the two existing shapes and the consumers being consolidated.

Is this the best way to solve the issue?

The patch uses the existing shared representation, updates active consumers together, and preserves the separately exposed BashResult and BashToolDetails contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 82ddbf657c58.

Provenance checked

  • Exec spill metadata keeps the original intent (202514e: Record exec output-file pointers and partial status so truncated output remains recoverable.)
  • Dual-shape spill lookup changes intended behavior with a stated reason (53b53f1: Support nested web_fetch spill metadata alongside the flat exec representation; this PR intentionally completes that consolidation.)
  • Persisted spill fields changes intended behavior with a stated reason (eb2f9be: Keep spill pointers and partial status when oversized details are summarized; the PR explicitly accepts dropping recovery through historical flat fields.)
  • Tokenjuice spill exclusion keeps the original intent (2237f16: Leave host spill recovery and timeout guidance intact instead of replacing them with compacted shell output.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit ad826fa adds src/agents/embedded-agent-runner/tool-result-truncation.ts:425 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ad826faf0dce; files: src/agents/embedded-agent-runner/tool-result-truncation.ts)
  • Peter Steinberger: Raw commit 475ea69 adds src/agents/embedded-agent-runner/tool-result-truncation.ts:431 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 475ea69f2c35; files: src/agents/embedded-agent-runner/tool-result-truncation.ts)
  • Vincent Koc: Raw commit 7df4392 adds src/agents/bash-tools.exec-result.types.ts:20 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 7df4392148cc; files: src/agents/bash-tools.exec-result.types.ts)

PR surface

Source -18, Tests -6. Total -24 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 10 28 -18
Tests 4 3 9 -6
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 13 37 -24

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: Released transcripts can contain flat exec spill metadata that this lookup no longer recognizes; that loss is explicitly accepted in the maintainer-authored PR.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.

Label justifications:

  • merge-risk: 🚨 compatibility: Released transcripts can contain flat exec spill metadata that this lookup no longer recognizes; that loss is explicitly accepted in the maintainer-authored PR.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record a v2026.11.10 session upgrade to the reviewed head and replay a newly persisted exec spill with its partial marker intact.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 27, 2026, 5:51 PM ET / 22:51 UTC.

…spill shape

Exec's flat fullOutputPath/spillTruncated become details.spill { path, truncated? },
the shape web_fetch and the record-time bound already use. Readers of the flat
fields (spill lookup, persistence allowlists, tokenjuice) are removed.

Co-authored-by: Ayaan Zaidi <[email protected]>
@obviyus
obviyus force-pushed the core/exec-spill-shape branch from 742a229 to e5978fc Compare November 27, 2026 22:54
@obviyus
obviyus merged commit 519d22d into main Nov 27, 2026
135 checks passed
@obviyus
obviyus deleted the core/exec-spill-shape branch November 27, 2026 23:10
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…spill shape (openclaw#206984)

## What Problem This Solves

A tool result can point to a file holding its full output. Two shapes record that pointer:
- web_fetch and the record-time bound (openclaw#206880) use `details.spill { path, chars?, truncated? }`;
- exec uses flat `details.fullOutputPath` plus `details.spillTruncated`.

So every reader handles both shapes:
- `getToolResultSpillDetails` (history elision and the bound's producer-spill reuse) falls back to the flat fields. It also reads a `spilledChars` field that nothing writes.
- The persisted-details allowlists keep both shapes (6 extra keys).
- The tokenjuice plugin checks exec's flat field to leave spilled results alone.

## Fix

Exec records `details.spill { path, truncated? }`, the one shape. Exec has bytes, not chars, so it does not set `chars`. The flat fields and every reader of them are removed:
- the flat fallback, and the never-written `spilledChars`, in `getToolResultSpillDetails`;
- `fullOutputPath`, `spilledChars` and `spillTruncated` in both persistence allowlists;
- tokenjuice now checks `details.spill`.

Accepted edge case: no migration. Exec results recorded before this change keep their text footer (`Full output: <path>`), but history elision no longer finds their pointer in `details`. The owner approved this. Spill files live in the OS temp directory anyway, so old pointers rarely outlive the session.

Not touched: `fullOutputPath` on the session `BashResult`/`BashToolDetails` types and the agent-core bash-execution message. Those are a different, extension-facing contract, and exec never writes them.

## User impact

None visible. The exec result text is unchanged. Model-visible behavior is the same: elision and the bound reuse exec's file as before, through the shared shape.

## Evidence

- `session-tool-result-guard.test.ts`: an exec output file cut at its limit records `spill: { path, truncated: true }`.
- `tool-result-truncation.test.ts`: history elision with an exec-shaped spill keeps its pointer.
- `runtime.integration.test.ts` (tokenjuice): a spilled exec result is left to the host.
- `tool-result-bounds.test.ts` (owner, unchanged) and `session-tool-result-guard.tool-result-persist-hook.test.ts` (fallback keeps `spill`) still pass.
- `bash-tools.exec-approval-output.test.ts`: a real exec spill path, read through workspace-only `read` (openclaw#206972), comes from `details.spill.path`.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: tokenjuice Changes to the bundled tokenjuice extension impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant