Skip to content

improve: send compact JSON tool results to the model - #196756

Merged
jalehman merged 6 commits into
mainfrom
refactor/compact-json-tool-results
Nov 10, 2026
Merged

jalehman merged 6 commits into
mainfrom
refactor/compact-json-tool-results

Conversation

@jalehman

@jalehman jalehman commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Tool results built with core jsonResult / payloadTextResult reach the model as 2-space pretty-printed JSON, which spends model context on indentation for every tool call. Code Mode makes this worse: the dispatch_action envelope escapes the indented text a second time. About 116 non-test files call jsonResult. That includes core tools, about 28 bundled plugins, and every feature-plugin tool through src/plugin-sdk/feature-plugin.ts (for example, Knowledge).

User Impact

User impact: agents spend roughly 20–25% fewer tokens on the JSON tool results this changes (about 2.5% of interactive and 8% of all transcript tokens in real sessions; see Evidence), with the same data. details, plugin APIs and config are unchanged. Control UI already renders JSON tool results with its own exact-lexeme JSON viewer, so its display is unchanged; Raw/Copy/Download keep the exact compact text. TUI renders JSON tool output literally instead of as Markdown.

Why This Change Was Made

jsonResult and payloadTextResult in src/agents/tools/tool-results.ts now emit JSON.stringify(payload). This is the single owner of the format. No flag or per-plugin opt-in was added, because no contract needed one: the SDK docs only named the helpers, and they now say the text is compact.

Siblings that copied that formatting, or measured budgets against it, now match the text that is actually sent:

  • Tool Search control results are always compact. The compact option, which only Code Mode passed, is removed. Batch search fitting and the tool_describe instructions-hint size check measure compact text.
  • Budget checks now measure the emitted text. Before, they measured pretty JSON and trimmed too early. This covers sessions_list fitting, the sessions patch resolved budget (its redundant pretty check is removed), the plugins tool result, the gateway config.get cap, update.run summary diagnostics trimming, and lobster maxStdoutBytes.
  • Other model-visible JSON is compact as well: the raw web_search branch, session_status route and state-change fenced JSON, ask_user and secrets note payloads, bundle LSP and MCP results, and the feishu, github and llm-task plugin result helpers.
  • Display: Control UI is unchanged; its existing JSON viewer already renders tool-result JSON with exact lexemes, so no display-only reformatting is added. The TUI treats JSON tool output as literal text, as it already did for Code Mode, so Markdown cannot alter values.

Deliberately left unchanged:

  • Human-facing output: feature-plugin registerCommand text, CLI --json output, and files written to disk (manifests, evidence, configs).
  • Codex and Agents API native transcript mirrors (event-projector-tool-items, session-catalog-transcript-item, agentsapi-native-items). They mirror another harness's items for display; they are not OpenClaw tool results sent to the model.
  • Codex context-engine-projection stableJson. It feeds Codex's rendered-context budget, which has its own owner and tests and needs separate review against the Codex harness.
  • llm-task inputJson, which is prompt input for a sub-model, not a tool result.
  • qa-lab rendering and reports.
  • extensions/knowledge, where result fields are being trimmed in a separate change.

Evidence

Model-visible bytes, measured by running representative payloads through the real helpers (jsonResult, feishuExternalToolResult, serializeToolSearchControlResult):

Result Before After Saved
Core sessions_list (12 rows, jsonResult) 5,999 4,711 21.5%
Channel plugin: feishu doc read (feishuExternalToolResult, external-content wrapped) 7,188 3,707 48.4%
Feature plugin: Knowledge-shaped search (10 hits, jsonResult) 5,079 3,673 27.7%
Code Mode dispatch_action envelope around that result 5,801 4,230 27.1%

The payloads are synthetic, but their shapes match production results. Direct-call tools save the indentation only; nested and Code Mode results also lose the escaped indentation. Separately, re-rendering 6,800 real Knowledge results from a trial cut model-visible size from 57.8M to 44.7M chars (−23%).

Token savings against real sessions

Measured by replaying 996 real local transcripts from the last 10 days (about 330M tokens: interactive dashboard sessions, cron automations and subagents) through current main formatting and through this PR. Tokens were counted with o200k_base as a proxy tokenizer. The baseline already includes main's compact dispatch_action envelope. Shell output, file reads and Code Mode results are unchanged by this PR and count as unchanged.

Sessions Count JSON share of tool tokens Saving, % of tool tokens Saving, % of all transcript tokens Per-session median (p90)
Interactive (dashboard) 110 17% 3.3% 2.5% 2.2% (6.6%)
Subagents 302 6.5% 1.4% 1.2% 0.8% (3.6%)
Cron automations 292 47% 10.6% 10.5% 10.7% (16.5%)
Knowledge-heavy (any kind) 100 82% 17.4% 16.1% 15.9% (20.3%)
Code Mode sessions 36 14% 2.6% 1.7% 0.0% (2.8%)
All 996 40% 8.9% 8.3% 3.1% (15.0%)

Results this PR changes lose about 22% of their tokens. The largest absolute savings come from sessions_list (−21%), sessions_history (−15%), tool_describe (−19%) and the knowledge_* tools (−15% to −28%). github_read is large but saves only about 5%, because its results are mostly file contents in a single string. These are transcript-token figures: compaction and prompt caching change billed tokens, but the relative savings should roughly carry over. A result that hits a size cap uses the same tokens and fits more content.

Tests run locally with node scripts/run-vitest.mjs:

  • src/plugin-sdk/tool-results.test.ts covers the compact contract. It fails on the base and passes with this change.
  • Sibling suites of every edited file pass: tool-search, code-mode, ask_user, gateway tool, plugins, secrets, sessions, session_status, web_search, LSP/MCP bundle, feishu, github, llm-task, TUI tool execution and Control UI tool output.
  • Updated exact-text expectations pass: task suggestion, computer refusal, sessions_list query, plugins tool, tool-search runtime, scheduled widget, sessions self-archive, browser, feishu docx table, MCP HTTP question authority, worker gateway tool runtime, and the code-mode-json budget.
  • A TUI test checks that compact JSON renders literally.
  • Final-head rerun of every updated-expectation file plus the MCP/LSP/gateway tool tests (20 files): all pass except extensions/voice-call/index.test.ts (EXIT=1, 370s wall). That failure is inherited from main: the same file fails the same way on b21829a4c85f in a clean worktree ("Voice call service is not running…", service runtime never starts, mock config unset). It does not touch JSON formatting.
  • Earlier batches: sibling suites 15 + 3 files pass (225s wall; infra shard re-run after a mid-run source edit, 17 files pass); review-fix batch passes.
  • pnpm check:changed on the final head (1304s): every lane passes except two that are not caused by this PR. The Plugin SDK surface budget fails the same way on main. The dead-export scan reports only files this PR does not touch.

No visual change: Control UI display code is untouched.

CI repair on the final head: the first CI run's failures were all caused by this PR (stale pretty-JSON expectations in tool-search, mcp-http and llm-task tests, a Control UI display reformat that broke the existing exact-lexeme JSON viewer, now reverted, and +4 test lines over the test-lines ratchet, now offset). Focused reruns of every failing file pass locally.

@clawsweeper

clawsweeper Bot commented Nov 10, 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 docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime extensions: llm-task Extension: llm-task extensions: lobster Extension: lobster agents Agent runtime and tooling channel: feishu Channel integration: feishu extensions: browser extensions: github GitHub plugin: link previews and reader size: S labels Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 45fde42cc005a2dbfb4985cafb44a482af47ad47
  • Maintainer: @jalehman
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/tools/secrets-tool.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR emits compact model-facing JSON, aligns output budgets, and preserves readable tool-result displays.

Example: A tool returns {"ok":true,"messageId":"msg-1"}.

  • Before: The model receives two-space-indented JSON.
  • After: The model receives {"ok":true,"messageId":"msg-1"}, while Control UI formats supported JSON for display.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation uses appropriate existing owners, but confirmed consumer-test failures and missing required visual evidence prevent readiness.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Indentation consumes model context and causes output budgets to discard useful data earlier.
Reason: The maintainer-authored direction removes recurring serialization waste without adding configuration or competing owners, and continues the formatting decision recorded in the earlier MCP work.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR open: compact serialization is a useful, maintainer-directed improvement, but the consumer-test cutover is incomplete.

Priority: P2
Reviewed head: 9f11d84014f49128696a34b629dda7ce71cffa5c

Before merge

  • Complete the compact-JSON cutover in consumer tests (P2) - Changing the shared text representation leaves several existing consumer suites red. Current-head CI annotations confirm that MCP HTTP still expects pretty {"status":"recorded"}, llm-task still expects indented foo/count results, Tool Search measures its 4,000-character cap by pretty-printing details, and Control UI tests still expect unformatted JSON in the displayed body. Update those expectations to the intended compact model text and formatted display, while retaining exact-byte assertions for Raw/Copy/Download. These failures follow directly from this change and need a focused test repair rather than unrelated CI work.

Findings

  • [P2] Complete the compact-JSON cutover in consumer tests — src/agents/tools/tool-results.ts:11

Tests

  • Missing end-to-end proof: Provide before/after Control UI and TUI captures exercising compact JSON display and showing that Raw, Copy, and Download retain the captured bytes.
Agent review details

How this fits together

Tool-result constructors turn payloads into model-facing text and structured details; budget owners bound that text, while Control UI and TUI render captured results.

flowchart LR
  A[Tool payload] --> B[Result constructors]
  B --> C[Compact JSON text]
  C --> D[Output budget checks]
  D --> E[Model request]
  C --> F[Captured tool result]
  F --> G[Control UI display]
  F --> H[TUI literal display]
Loading

Technical review

Best possible solution:

Keep compact serialization in the existing owners and complete the affected consumer-test expectations without restoring server-side indentation.

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

Current-main source directly shows repeated pretty serialization, and current-head GitHub annotations demonstrate the consumer expectations affected by replacing it.

Is this the best way to solve the issue?

The existing result constructors are the right owners, and aligning budget measurements with emitted bytes is the smallest complete approach; display formatting appropriately remains at the presentation boundary.

Full review comments:

  • [P2] Complete the compact-JSON cutover in consumer tests — src/agents/tools/tool-results.ts:11
    Changing the shared text representation leaves several existing consumer suites red. Current-head CI annotations confirm that MCP HTTP still expects pretty {"status":"recorded"}, llm-task still expects indented foo/count results, Tool Search measures its 4,000-character cap by pretty-printing details, and Control UI tests still expect unformatted JSON in the displayed body. Update those expectations to the intended compact model text and formatted display, while retaining exact-byte assertions for Raw/Copy/Download. These failures follow directly from this change and need a focused test repair rather than unrelated CI work.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 109b0cc2e9b5.

Provenance checked

  • Shared JSON and payload-result constructors changes intended behavior with a stated reason (bfffa95: The SDK consolidation preserved identical pretty-JSON constructors; the later payload consolidation in b018452 likewise preserved existing serialization.)
  • Tool Search and Code Mode serialization keeps the original intent (8678a47: Budget fitting and delivery share serialization so formatting cannot consume unreserved context; this PR extends the existing compact path to all control results.)
  • Control UI formatting and exact output export keeps the original intent (5c1c507: Readable presentation must preserve number and string lexemes, duplicate members, and original Raw/Copy/Download bytes; this PR reuses that formatter for ordinary JSON results.)
  • TUI literal rendering keeps the original intent (8678a47: Compact Code Mode JSON required literal rendering to prevent Markdown from altering displayed values; this PR applies that same behavior to recognized JSON tool output.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/agents/tool-search.test.ts src/gateway/mcp-http.test.ts extensions/llm-task/src/llm-task-tool.test.ts --maxWorkers=1
  • pnpm --dir ui exec vitest run src/pages/chat/components/chat-tool-cards.test.tsx src/pages/chat/components/chat-json-text.test.ts src/pages/chat/components/chat-tool-output.test.ts
  • pnpm check:changed
  • git diff --check

What I checked:

Likely related people:

  • Dallin Romney: Raw commit bfffa95 adds src/agents/tools/tool-results.ts:3 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bfffa950d71c; files: src/agents/tools/tool-results.ts)
  • Vincent Koc: Raw commit b018452 adds src/agents/tools/tool-results.ts:14 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b01845283f09; files: src/agents/tools/tool-results.ts)
  • Peter Steinberger: Raw commit 5b4f3a4 adds ui/src/lib/chat/tool-output.ts:85 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5b4f3a4c00e1; files: ui/src/lib/chat/tool-output.ts)

PR surface

Source +3, Tests +16, Docs +1. Total +20 across 44 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 25 53 50 +3
Tests 18 38 22 +16
Docs 1 2 1 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 44 93 73 +20

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 P2: This is a useful context-efficiency improvement with focused consumer-test repairs.
  • add merge-risk: 🚨 compatibility: The public jsonResult helper changes its exact text representation; maintainer direction accepts compact whitespace, while signatures and structured payloads remain intact.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This is a useful context-efficiency improvement with focused consumer-test repairs.
  • merge-risk: 🚨 compatibility: The public jsonResult helper changes its exact text representation; maintainer direction accepts compact whitespace, while signatures and structured payloads remain intact.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 10, 2026, 12:26 PM ET / 17:26 UTC.

@openclaw-barnacle openclaw-barnacle Bot removed the app: web-ui App: web-ui label Nov 10, 2026
@jalehman
jalehman enabled auto-merge (squash) November 10, 2026 21:02
@jalehman
jalehman merged commit 3d6699c into main Nov 10, 2026
130 of 133 checks passed
@jalehman
jalehman deleted the refactor/compact-json-tool-results branch November 10, 2026 21:05
roboclaw-bot added a commit that referenced this pull request Nov 11, 2026
Complete the consumer expectation cutover from #196756. Keep full result equality, original typed details and all registration/config assertions. Actual affected test fails before correction; both helper and plugin files pass all six tests after correction.

Co-authored-by: obviyus <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 12, 2026
## What Problem This Solves

An agent cannot collect an already-finished background process when unrelated Code Mode continuations fill all 64 suspended-run slots. The fresh observer fails before reaching `process`, even with outer `awaitResults: true`.

## User Impact and Solution

Required-completion cells keep their owner until settlement and cannot publish suspended continuations, so they no longer reserve a suspension slot at inline dispatch or checkpoint settlement. Agents can collect the original process result without relaunching work. Capacity errors and troubleshooting guidance explain this recovery path.

Default suspension admission, existing-run reservation transfer, process retention, authority checks, and cancellation are unchanged. This complements #196435's rejected-cell settlement fix; it addresses fresh-observer admission rather than process-output loss. It intentionally permits actively owned required-completion cells at the suspension cap, not a new total-live-cell resource limit.

## Evidence

- One real native background process and 64 genuine parked VM continuations: default observation fails without dispatch; required observation retrieves the original terminal output. Assertions retain one launch, one poll, the 64-slot cap, active-resume reservation, cancellation, and capacity recovery.
- Regression fails on base `5e8ed5f5b437e3a8438a036eb42c4d98009d0d86`, passes with the fix.
- Seven focused suites: **169 tests passed**, including agent-loop recovery, Node/QuickJS failure origins, required wait/cancellation, shell terminal draining, bridge behavior, and prompt-prefix stability.
- Core and changed-test TypeScript, targeted type-aware lint, formatting, MDX, and diff checks passed.
- Exact **59-line** allocation records the native-process setup and assertions added to the existing capacity test; shared scalar unchanged. Local test-line ratchet passes with 17 lines slack, and the previous head's complete baseline-ratchet CI passed. Saturation test takes about 2 seconds locally.
- No new queue, quota, recovery manager, or persistent state. Production delta: 9 added / 3 removed lines.

## CI repairs

Earlier heads exposed two inherited worker containment expectation failures in `checks-node-changed-11`. Source inspection and base reproduction established stale expectations after #194473's root-aware recovery and #196756's compact JSON serialization. Current main `18adeb3f1768b3c1371b3c294f06397d5cb352ea` still had those expectations; no competing fix was found.

The follow-up updates only `src/worker/worker-runtime-permissions.suite.ts`: independent per-policy literal expectations and exact compact JSON output. Rejection status, tool name, escaped path, operator-only hint separation/logging, unchanged outside-file contents, and file-mode assertions remain intact. No permission behavior, ignores, retries, or gates were weakened.

- `node scripts/run-vitest.mjs src/worker/worker.runtime.test.ts --maxWorkers=1`: **69 passed**, 40.79 seconds suite / 47.24 seconds wrapper. The existing suite's real background-process cleanup tests dominate duration; the two repaired cases take 29/24 ms.
- Changed-test TypeScript graph (`gateway-other`), type-aware lint, formatting, diff check, and test-line ratchet passed.
- New-head CI is being evaluated separately; previous-head results are not claimed as current-head CI proof.

## Review and limitations

Independent native-subagent reviews of the implementation, exact allocation, and worker repair found no actionable defects. Local reviewer CLIs and bound autoreview tool were unavailable; no review tools were installed. These were narrative independent reviews, not helper-enforced isolation or structured helper validation. Hosted review of `1269cc403ec7243b847eb4cbec0ff0b5a8d08f6e` also reported no findings.

The new saturation case executes Node. QuickJS support is backed by shared owner-path inspection and existing parity/failure tests, not a separate saturation run. No shipped Gateway/live-model saturation capture or guarantee of model recovery choices is claimed; proof exercises the actual Code Mode/native-process integration boundary.

## Main integration (November 11, 2026)

Merged main into the published PR branch without rewriting history (head `33a9fa55f09e6cbb41300cc0aa67ee9ef2edf94b`). Verified tree equivalence with the reviewed rebase plus the disjoint main update. The equivalent rebased code passed the native-process capacity regression and 69 worker tests, targeted type-aware lint, and formatting. The final merge passed diff checks and the test-line ratchet with 10 lines slack; no shared budget increase. Updated-head CI verified on November 11, 2026: 71 checks passed, 59 skipped, no failures or pending checks on `33a9fa55f09e6cbb41300cc0aa67ee9ef2edf94b`. The PR remains open; no merge was performed.

## Main conflict resolution (November 12, 2026)

Merged main `4947e40db109` normally into the PR without force-pushing. New head: `225c5b5bcf06f45ef6018580425bc94349c1b9c2`. The only conflict was in the worker containment test: main now has the same corrected messages and compact JSON expectation. Kept the already-reviewed independent per-policy literal expectations; no new production behavior. The database-worker test inventory auto-merged both additions.

Scoped proof on the integrated tree: native-process saturation regression passed; all 69 worker runtime tests passed; worker test typecheck, type-aware lint, formatting, and diff check passed. Existing implementation review remains applicable to this mechanical integration. The initial worker invocation hit unresolved conflict markers after a failed editing command; the corrected complete worker suite passed. Current-head CI is pending and is required before merge; previous-head green checks are not claimed as current proof.

<!-- openclaw-publication:496957c8-5491-47fa-9565-7ecf6d229daa -->
RomneyDa added a commit that referenced this pull request Nov 12, 2026
Align the native hook relay middleware expectation with the compact payload serializer introduced by #196756. Retain exact result content and details assertions.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 12, 2026
* fix: bound transcript reads before native context seeding

Co-authored-by: RomneyDa <[email protected]>

* fix: reduce transcript allocation when preparing native context seeds

OpenClaw-Publication: 294c8539-9e0b-4d17-aef7-76eb33f15e8b

* fix: preserve lightweight native seed reader imports

Move shared selection and token accounting into existing pure leaf owners without loading compaction transports or the agent runtime. Preserve the transcript-reader isolation introduced by #162609 and package only the required leaf closure.

Co-authored-by: RomneyDa <[email protected]>

* Publish openclaw/bound-context-read-pr

OpenClaw-Publication: 09aca01f-b368-487f-97eb-dbb64b0b376f

* Publish openclaw/bound-context-read-pr

OpenClaw-Publication: 9793f742-04ad-4d1a-b977-7ebd074e7f63

* fix(sessions): satisfy bounded seed CI ratchets

Build last-member JSON lookup with typed Kysely. Keep deterministic hydration assertions without repeated timing samples and allocate exactly the remaining 250 regression-test lines.

Co-authored-by: RomneyDa <[email protected]>

* Publish openclaw/bound-context-read-pr

OpenClaw-Publication: beebe320-4be9-4844-bf45-651370b69c83

* Publish openclaw/bound-context-read-pr

OpenClaw-Publication: d07a04d5-f480-4414-994f-c5feed6be860

* test(codex): expect compact native tool result JSON

Align the native hook relay middleware expectation with the compact payload serializer introduced by #196756. Retain exact result content and details assertions.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>

* Publish openclaw/bound-context-read-pr

OpenClaw-Publication: 63a451db-f5c9-453b-96f0-72ed26ba3893

---------

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 12, 2026
…aw#197068)

Align the Telegram loopback assertion with the compact answered-result text intentionally introduced by openclaw#196756. Preserve the exact answered status, successful text result, Bot API prompt and authority/cleanup assertions. No production, retry or timeout changes.

Co-authored-by: steipete <[email protected]>
Co-authored-by: obviyus <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 12, 2026
…openclaw#197082)

Align the worker permission fixture with source-specific containment recovery guidance introduced by openclaw#194473 and compact JSON results introduced by openclaw#196756. Preserve exact denial, outside-file contents/mode and operator-only hint assertions. No production permission policy changes.

Proof: independent isolated review clean; source-extracted diagnostic red/green checks for configured and guarded modes; exact-head CI 42974054691 passed changed tests, boundary checks, lint/types, ratchets and ci-gate. Local named runtime test could not collect without task dependencies; no local integration success claimed.

Co-authored-by: steipete <[email protected]>
Co-authored-by: obviyus <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 12, 2026
…97222)

Complete the consumer expectation cutover from openclaw#196756. Keep full result equality, original typed details and all registration/config assertions. Actual affected test fails before correction; both helper and plugin files pass all six tests after correction.

Co-authored-by: obviyus <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 12, 2026
## What Problem This Solves

An agent cannot collect an already-finished background process when unrelated Code Mode continuations fill all 64 suspended-run slots. The fresh observer fails before reaching `process`, even with outer `awaitResults: true`.

## User Impact and Solution

Required-completion cells keep their owner until settlement and cannot publish suspended continuations, so they no longer reserve a suspension slot at inline dispatch or checkpoint settlement. Agents can collect the original process result without relaunching work. Capacity errors and troubleshooting guidance explain this recovery path.

Default suspension admission, existing-run reservation transfer, process retention, authority checks, and cancellation are unchanged. This complements openclaw#196435's rejected-cell settlement fix; it addresses fresh-observer admission rather than process-output loss. It intentionally permits actively owned required-completion cells at the suspension cap, not a new total-live-cell resource limit.

## Evidence

- One real native background process and 64 genuine parked VM continuations: default observation fails without dispatch; required observation retrieves the original terminal output. Assertions retain one launch, one poll, the 64-slot cap, active-resume reservation, cancellation, and capacity recovery.
- Regression fails on base `d53716c9b1671e5509516227f720722e25d9e1d4`, passes with the fix.
- Seven focused suites: **169 tests passed**, including agent-loop recovery, Node/QuickJS failure origins, required wait/cancellation, shell terminal draining, bridge behavior, and prompt-prefix stability.
- Core and changed-test TypeScript, targeted type-aware lint, formatting, MDX, and diff checks passed.
- Exact **59-line** allocation records the native-process setup and assertions added to the existing capacity test; shared scalar unchanged. Local test-line ratchet passes with 17 lines slack, and the previous head's complete baseline-ratchet CI passed. Saturation test takes about 2 seconds locally.
- No new queue, quota, recovery manager, or persistent state. Production delta: 9 added / 3 removed lines.

## CI repairs

Earlier heads exposed two inherited worker containment expectation failures in `checks-node-changed-11`. Source inspection and base reproduction established stale expectations after openclaw#194473's root-aware recovery and openclaw#196756's compact JSON serialization. Current main `ecfec37bdb3551b3555550d398d19655c9327a9f` still had those expectations; no competing fix was found.

The follow-up updates only `src/worker/worker-runtime-permissions.suite.ts`: independent per-policy literal expectations and exact compact JSON output. Rejection status, tool name, escaped path, operator-only hint separation/logging, unchanged outside-file contents, and file-mode assertions remain intact. No permission behavior, ignores, retries, or gates were weakened.

- `node scripts/run-vitest.mjs src/worker/worker.runtime.test.ts --maxWorkers=1`: **69 passed**, 40.79 seconds suite / 47.24 seconds wrapper. The existing suite's real background-process cleanup tests dominate duration; the two repaired cases take 29/24 ms.
- Changed-test TypeScript graph (`gateway-other`), type-aware lint, formatting, diff check, and test-line ratchet passed.
- New-head CI is being evaluated separately; previous-head results are not claimed as current-head CI proof.

## Review and limitations

Independent native-subagent reviews of the implementation, exact allocation, and worker repair found no actionable defects. Local reviewer CLIs and bound autoreview tool were unavailable; no review tools were installed. These were narrative independent reviews, not helper-enforced isolation or structured helper validation. Hosted review of `1269cc403ec7243b847eb4cbec0ff0b5a8d08f6e` also reported no findings.

The new saturation case executes Node. QuickJS support is backed by shared owner-path inspection and existing parity/failure tests, not a separate saturation run. No shipped Gateway/live-model saturation capture or guarantee of model recovery choices is claimed; proof exercises the actual Code Mode/native-process integration boundary.

## Main integration (November 11, 2026)

Merged main into the published PR branch without rewriting history (head `33a9fa55f09e6cbb41300cc0aa67ee9ef2edf94b`). Verified tree equivalence with the reviewed rebase plus the disjoint main update. The equivalent rebased code passed the native-process capacity regression and 69 worker tests, targeted type-aware lint, and formatting. The final merge passed diff checks and the test-line ratchet with 10 lines slack; no shared budget increase. Updated-head CI verified on November 11, 2026: 71 checks passed, 59 skipped, no failures or pending checks on `33a9fa55f09e6cbb41300cc0aa67ee9ef2edf94b`. The PR remains open; no merge was performed.

## Main conflict resolution (November 12, 2026)

Merged main `ec930d1030e9` normally into the PR without force-pushing. New head: `225c5b5bcf06f45ef6018580425bc94349c1b9c2`. The only conflict was in the worker containment test: main now has the same corrected messages and compact JSON expectation. Kept the already-reviewed independent per-policy literal expectations; no new production behavior. The database-worker test inventory auto-merged both additions.

Scoped proof on the integrated tree: native-process saturation regression passed; all 69 worker runtime tests passed; worker test typecheck, type-aware lint, formatting, and diff check passed. Existing implementation review remains applicable to this mechanical integration. The initial worker invocation hit unresolved conflict markers after a failed editing command; the corrected complete worker suite passed. Current-head CI is pending and is required before merge; previous-head green checks are not claimed as current proof.

<!-- openclaw-publication:496957c8-5491-47fa-9565-7ecf6d229daa -->
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 12, 2026
* fix: bound transcript reads before native context seeding

Co-authored-by: RomneyDa <[email protected]>

* fix: reduce transcript allocation when preparing native context seeds

OpenClaw-Publication: 294c8539-9e0b-4d17-aef7-76eb33f15e8b

* fix: preserve lightweight native seed reader imports

Move shared selection and token accounting into existing pure leaf owners without loading compaction transports or the agent runtime. Preserve the transcript-reader isolation introduced by openclaw#162609 and package only the required leaf closure.

Co-authored-by: RomneyDa <[email protected]>

* Publish openclaw/bound-context-read-pr

OpenClaw-Publication: 09aca01f-b368-487f-97eb-dbb64b0b376f

* Publish openclaw/bound-context-read-pr

OpenClaw-Publication: 9793f742-04ad-4d1a-b977-7ebd074e7f63

* fix(sessions): satisfy bounded seed CI ratchets

Build last-member JSON lookup with typed Kysely. Keep deterministic hydration assertions without repeated timing samples and allocate exactly the remaining 250 regression-test lines.

Co-authored-by: RomneyDa <[email protected]>

* Publish openclaw/bound-context-read-pr

OpenClaw-Publication: beebe320-4be9-4844-bf45-651370b69c83

* Publish openclaw/bound-context-read-pr

OpenClaw-Publication: d07a04d5-f480-4414-994f-c5feed6be860

* test(codex): expect compact native tool result JSON

Align the native hook relay middleware expectation with the compact payload serializer introduced by openclaw#196756. Retain exact result content and details assertions.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>

* Publish openclaw/bound-context-read-pr

OpenClaw-Publication: 63a451db-f5c9-453b-96f0-72ed26ba3893

---------

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Heetisk added a commit to Heetisk/openclaw that referenced this pull request Nov 13, 2026
…ith compact JSON

- Restore buildBootstrapContextFiles' [MISSING] Expected at: <absolute path>
  marker so the exported agent-harness-runtime SDK consumer contract is
  unchanged. Prompt preparation (prepareContextFilesForPrompt) still renders
  workspace-relative markers via the new missing flag, keeping the
  cross-workspace prefix-cache parity from openclaw#191485.
- Align run-attempt.native-hook-relay.test.ts with compact JSON tool results
  from openclaw#196756 (main 3d6699c changed payloadTextResult serialization after
  this branch point; the stale pretty-JSON expectation fails the merged-tree
  shard).
RomneyDa added a commit that referenced this pull request Nov 14, 2026
…during compaction (#196550)

* fix: reduce Gateway heap spikes during long-session compaction

OpenClaw-Publication: 3c8ed9c2-cdf2-4a3e-9cfc-cb237d488ace

* fix: reuse compaction facts without repeated transcript parsing

OpenClaw-Publication: b899f5e4-7fb9-46f0-9b19-635e33a8b99c

* Publish openclaw/keen-prawn

OpenClaw-Publication: 33dc62a0-c779-4768-97d2-4b3fa2323cdf

* Publish openclaw/keen-prawn

OpenClaw-Publication: f8c0512a-6354-4487-b291-d85f50f68262

* fix: reconcile compaction regression-test allocation

OpenClaw-Publication: 90ea6a98-3750-4df1-8f07-6333b0ba229c

* fix(compaction): free the compaction worker during summary model calls

* fix: match compaction concurrency test-line credit to its net growth

* perf(compaction): check only captured rows before rerendering summary input

* test: align worker containment and Claude fallback tests with main contracts

main #194473 reworded the file-tool containment hint per source and #196756 compacted tool-result JSON; main #196459 gave unknown Claude ids mandatory adaptive thinking, so the non-reasoning fallback fixture uses a pre-Claude-5 id.

* refactor(compaction): keep preflight metadata in its reader

Co-authored-by: RomneyDa <[email protected]>

* fix(compaction): detach bounded floor facts from transcript payloads

Prevent small excerpts and identifier captures from retaining whole source strings while a compaction plan is cached. Add a GC retention regression for the owning producer.

Co-authored-by: RomneyDa <[email protected]>

* fix(workers): defer slow idle GC logging imports

Keep the slow-GC diagnostic behind its own lazy operation boundary so small workers do not eagerly evaluate the logging graph. Preserve collection thresholds and warning fields.

The existing production build gate reproduces 240 identity-worker modules on the base and passes at 203 after the repair (budget 220 unchanged). Full and sourcePerformance builds, 11 focused worker tests, infra typecheck, lint, and format checks pass. Independent native review found no actionable P0/P1/P2 findings; local autoreview was unavailable because Codex was not installed.

Co-authored-by: RomneyDa <[email protected]>

* fix: complete compaction wrapper inventory

Co-authored-by: RomneyDa <[email protected]>

---------

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 15, 2026
…during compaction (openclaw#196550)

* fix: reduce Gateway heap spikes during long-session compaction

OpenClaw-Publication: 3c8ed9c2-cdf2-4a3e-9cfc-cb237d488ace

* fix: reuse compaction facts without repeated transcript parsing

OpenClaw-Publication: b899f5e4-7fb9-46f0-9b19-635e33a8b99c

* Publish openclaw/keen-prawn

OpenClaw-Publication: 33dc62a0-c779-4768-97d2-4b3fa2323cdf

* Publish openclaw/keen-prawn

OpenClaw-Publication: f8c0512a-6354-4487-b291-d85f50f68262

* fix: reconcile compaction regression-test allocation

OpenClaw-Publication: 90ea6a98-3750-4df1-8f07-6333b0ba229c

* fix(compaction): free the compaction worker during summary model calls

* fix: match compaction concurrency test-line credit to its net growth

* perf(compaction): check only captured rows before rerendering summary input

* test: align worker containment and Claude fallback tests with main contracts

main openclaw#194473 reworded the file-tool containment hint per source and openclaw#196756 compacted tool-result JSON; main openclaw#196459 gave unknown Claude ids mandatory adaptive thinking, so the non-reasoning fallback fixture uses a pre-Claude-5 id.

* refactor(compaction): keep preflight metadata in its reader

Co-authored-by: RomneyDa <[email protected]>

* fix(compaction): detach bounded floor facts from transcript payloads

Prevent small excerpts and identifier captures from retaining whole source strings while a compaction plan is cached. Add a GC retention regression for the owning producer.

Co-authored-by: RomneyDa <[email protected]>

* fix(workers): defer slow idle GC logging imports

Keep the slow-GC diagnostic behind its own lazy operation boundary so small workers do not eagerly evaluate the logging graph. Preserve collection thresholds and warning fields.

The existing production build gate reproduces 240 identity-worker modules on the base and passes at 203 after the repair (budget 220 unchanged). Full and sourcePerformance builds, 11 focused worker tests, infra typecheck, lint, and format checks pass. Independent native review found no actionable P0/P1/P2 findings; local autoreview was unavailable because Codex was not installed.

Co-authored-by: RomneyDa <[email protected]>

* fix: complete compaction wrapper inventory

Co-authored-by: RomneyDa <[email protected]>

---------

Co-authored-by: RomneyDa <[email protected]>
Heetisk added a commit to Heetisk/openclaw that referenced this pull request Nov 16, 2026
…ith compact JSON

- Restore buildBootstrapContextFiles' [MISSING] Expected at: <absolute path>
  marker so the exported agent-harness-runtime SDK consumer contract is
  unchanged. Prompt preparation (prepareContextFilesForPrompt) still renders
  workspace-relative markers via the new missing flag, keeping the
  cross-workspace prefix-cache parity from openclaw#191485.
- Align run-attempt.native-hook-relay.test.ts with compact JSON tool results
  from openclaw#196756 (main 3d6699c changed payloadTextResult serialization after
  this branch point; the stale pretty-JSON expectation fails the merged-tree
  shard).
Heetisk added a commit to Heetisk/openclaw that referenced this pull request Nov 19, 2026
…ith compact JSON

- Restore buildBootstrapContextFiles' [MISSING] Expected at: <absolute path>
  marker so the exported agent-harness-runtime SDK consumer contract is
  unchanged. Prompt preparation (prepareContextFilesForPrompt) still renders
  workspace-relative markers via the new missing flag, keeping the
  cross-workspace prefix-cache parity from openclaw#191485.
- Align run-attempt.native-hook-relay.test.ts with compact JSON tool results
  from openclaw#196756 (main 3d6699c changed payloadTextResult serialization after
  this branch point; the stale pretty-JSON expectation fails the merged-tree
  shard).
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
)

(cherry picked from commit b65961b)

Release adaptation: bounded override guard and corresponding regression. Later openclaw#196756 compact JSON output is not a model-resolution prerequisite. Diff check passed; focused tests require missing shared configuration dependency @solidjs/vite-plugin.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 5006a76530e816ec56011dabd5e8aad8ffa91790)
(cherry picked from commit 8715be0d6eefe4e4542c2fc0c009301d347f7497)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: feishu Channel integration: feishu docs Improvements or additions to documentation extensions: browser extensions: github GitHub plugin: link previews and reader extensions: llm-task Extension: llm-task extensions: lobster Extension: lobster gateway Gateway runtime 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. security-sensitive-changed size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant