Skip to content

fix(agents): keep tool_use and toolResult together when splitting messages - #58849

Merged
obviyus merged 4 commits into
openclaw:mainfrom
openperf:fix/compaction-tool-use-split
Apr 4, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
openperf:fix/compaction-tool-use-split

Conversation

@openperf

@openperf openperf commented Apr 1, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Problem: splitMessagesByTokenShare in src/agents/compaction.ts splits message arrays purely by token count. This can cause a split to land exactly between an assistant message containing a tool_use block and its corresponding toolResult message. This results in chunks with orphaned tool calls or orphaned tool results, which are rejected by strict APIs (like Anthropic) during summarizeInStages.
  • Root Cause: The split decision (currentTokens + messageTokens > targetTokens) did not consider the semantic boundary between tool calls and their results. It blindly cut the array, breaking the invariant that a toolResult must immediately follow its matching assistant turn.
  • Fix: Introduced a pendingToolCallIds set to track tool call boundaries during the iteration. When an assistant message contains tool calls, the split is deferred until all matching toolResult messages are consumed. This guarantees that tool_use and toolResult pairs are never separated into different chunks.
  • What changed:
    • src/agents/compaction.ts: Added boundary tracking logic in splitMessagesByTokenShare.
    • src/agents/compaction.test.ts: Added two regression tests to verify that tool_use and toolResult pairs (including multiple results for a single assistant turn) stay in the same chunk.
  • What did NOT change (scope boundary): Did not modify chunkMessagesByMaxTokens (which operates on messages that have already had tool result details stripped), and did not change the downstream repair logic in session-transcript-repair.ts.

Reproduction

  1. Have a conversation where the agent makes a tool call, and the tool returns a very large result.
  2. The context grows large enough to trigger summarizeInStages.
  3. splitMessagesByTokenShare cuts the history into chunks. If the token boundary falls right after the assistant tool call but before the toolResult, the resulting chunk sent to the LLM for summarization contains an orphaned tool_use, causing an API rejection (e.g., "unexpected tool_use_id").

Risk / Mitigation

  • Risk: Deferring splits could cause a chunk to exceed its token target if a tool result is massive.
  • Mitigation: This is acceptable and handled by downstream code. splitMessagesByTokenShare is a soft-split for summarization parts. The actual summarization call (summarizeChunks) already uses chunkMessagesByMaxTokens as a hard limit and strips tool result details before sending to the LLM, so a slightly larger logical chunk here will not cause context window overflows.

Change Type (select all)

  • Bug fix

Scope (select all touched areas)

  • Agents

Linked Issue/PR

Fixes #58836

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Apr 1, 2026
@openperf openperf changed the title fix(compaction): keep tool_use and toolResult together when splitting messages fix(agents): keep tool_use and toolResult together when splitting messages Apr 1, 2026
@aisle-research-bot

aisle-research-bot Bot commented Apr 1, 2026 •

Copy link
Copy Markdown

🔒 Aisle Security Analysis

We found 2 potential security issue(s) in this PR:

# Severity Title
1 🟡 Medium Potential Denial of Service via stalled chunk splitting when toolResult lacks/mismatches tool call ID
2 🟡 Medium Tool call/result pairing can be broken by chunk splitting when non-tool messages intervene
1. 🟡 Potential Denial of Service via stalled chunk splitting when toolResult lacks/mismatches tool call ID
Property Value
Severity Medium
CWE CWE-400
Location src/agents/compaction.ts:157-185

Description

In splitMessagesByTokenShare, chunk splitting is gated on pendingToolCallIds.size === 0 to keep an assistant tool call and its matching toolResult(s) in the same chunk.

However, if a toolResult message is malformed (missing toolCallId/toolUseId) or carries a non-matching ID:

  • extractToolResultId(message) returns null
  • The pending set is never reduced
  • The split gate stays closed for the remainder of a run of toolResult messages
  • splitMessagesByTokenShare may return a single huge chunk, causing pruneHistoryForContextShare to stop dropping history (chunks.length <= 1), potentially leaving history above budget

This can lead to context overflow / repeated API failures and elevated CPU/memory due to oversized compaction/summarization attempts (a practical application-level DoS if transcripts can contain malformed tool results, e.g., from corrupted session history or buggy integrations).

Vulnerable code:

} else if (message.role === "toolResult" && pendingToolCallIds.size > 0) {
  const resultId = extractToolResultId(message);
  if (resultId) {
    pendingToolCallIds.delete(resultId);
  }
  ​// ... splitting depends on pendingToolCallIds.size === 0
}

Recommendation

Make pending tracking fail-open when encountering malformed/unmatched tool results so compaction can still split and enforce budgets.

Options (choose one):

  1. Clear pending on toolResult without an ID (safest for budget enforcement):
} else if (message.role === "toolResult" && pendingToolCallIds.size > 0) {
  const resultId = extractToolResultId(message);
  if (!resultId) {
    ​// Malformed toolResult; don't let it block chunking indefinitely.
    pendingToolCallIds.clear();
  } else {
    pendingToolCallIds.delete(resultId);
  }
  ​// existing post-clear split check...
}
  1. Add a bounded escape hatch, e.g., if more than N toolResult messages arrive without clearing pending, clear pending and continue splitting.

Also consider logging when this fallback triggers so corrupted transcripts can be detected and repaired upstream.

2. 🟡 Tool call/result pairing can be broken by chunk splitting when non-tool messages intervene
Property Value
Severity Medium
CWE CWE-345
Location src/agents/compaction.ts:159-189

Description

In splitMessagesByTokenShare, pending tool call IDs are cleared for any message that is neither an assistant nor a toolResult:

  • pendingToolCallIds is set when an assistant contains tool calls.
  • If a user/system/annotation message appears before the matching toolResult, the else branch clears pending IDs.
  • A subsequent token-budget split can then occur between the assistant tool call and its tool result(s).
  • summarizeInStages uses this splitting without repairing transcripts, so summaries can be generated from chunks where:
    • tool calls appear without their results, and/or
    • tool results appear without their corresponding tool calls.

Because the codebase explicitly acknowledges that session files can have tool results displaced (see repairToolUseResultPairing), the assumption that tool results “should directly follow their assistant turn” is not guaranteed. This creates an integrity/correctness failure that can misrepresent tool execution history and potentially lead to tool confusion in downstream logic.

Vulnerable code:

} else {
  ​// Any non-assistant, non-toolResult message clears pending tracking,
  ​// since tool results should directly follow their assistant turn.
  pendingToolCallIds = new Set();
}

Recommendation

Do not clear pendingToolCallIds merely because a non-tool message appears between an assistant tool call and its tool result(s).

Safer options:

  1. Keep pending IDs across intervening non-assistant messages, only clearing when:
  • you encounter a new assistant message (which starts a new turn), or
  • you’ve consumed all expected tool results.

Example adjustment:

} else if (message.role === "toolResult" && pendingToolCallIds.size > 0) {
  const resultId = extractToolResultId(message);
  if (resultId) pendingToolCallIds.delete(resultId);
  ​// ... existing split-after-consumed logic ...
} else if (message.role === "assistant") {
  ​// ... existing assistant handling ...
} else {
  ​// Keep pending tool call IDs across user/system/annotation messages
  ​// because toolResults may be displaced.
  ​// pendingToolCallIds unchanged.
}
  1. If you must bound this for pathological transcripts, consider a maximum lookahead (e.g., clear pending after N messages or when encountering another assistant turn).

Also add a regression test where an intervening user/system message occurs between assistant(toolCall) and toolResult to ensure they remain in the same chunk (or that the split strategy explicitly accounts for this ordering).


Analyzed PR: #58849 at commit f533339

Last updated on: 2026-04-01T08:56:40Z

@greptile-apps

greptile-apps Bot commented Apr 1, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a real bug in splitMessagesByTokenShare where a token-count split could land between an assistant message containing tool_use blocks and its corresponding toolResult messages, producing chunks that strict APIs (like Anthropic) reject with "unexpected tool_use_id" errors during summarizeInStages. The fix correctly introduces a pendingToolCallIds set that defers chunk boundaries until all toolResult messages for the last assistant turn have been consumed.

The core logic in compaction.ts is sound, and the two new regression tests in compaction.test.ts exercise the fix well. However, the behavioral change has a side-effect on the existing pruneHistoryForContextShare tests:

  • "removes orphaned tool_result messages when tool_use is dropped" — previously the split placed the toolResult into the kept chunk (orphaned); now both the assistant and toolResult land in the same (dropped) chunk. The assertion expect(pruned.droppedMessages).toBeGreaterThan(pruned.droppedMessagesList.length) becomes 2 > 2 and will fail.
  • "removes multiple orphaned tool_results from the same dropped tool_use" — same structural change; the assertion expect(pruned.droppedMessages).toBe(pruned.droppedMessagesList.length + 2) becomes 3 === 5 and will fail.

These two tests must be updated to reflect the corrected split behavior before merging.

Confidence Score: 4/5

Not safe to merge until the two broken existing pruneHistoryForContextShare tests are fixed.

The fix itself is logically correct and addresses the root cause of orphaned tool_use/toolResult splits. However, at least two pre-existing tests in the pruneHistoryForContextShare suite have assertions written to observe the OLD buggy behavior where orphaned tool_results landed in the kept chunk. With the new fix those tool_results stay in the dropped chunk alongside their assistant message, causing the orphan-count assertions to fail. Until those tests are updated the PR cannot be merged without a red CI.

src/agents/compaction.test.ts — the two pruneHistoryForContextShare tests at lines 218–250 and 279–319 need their orphan-count assertions updated to reflect the new behavior.

Comments Outside Diff (1)

  1. src/agents/compaction.test.ts, line 218-250 (link)

    P1 Existing tests broken by the new split behavior

    Two existing pruneHistoryForContextShare tests will fail after this change because their assertions are built around the OLD behavior where splitMessagesByTokenShare could land between a tool_use and its toolResult.

    Test 1 — "removes orphaned tool_result messages when tool_use is dropped" (lines 218–250):

    With the new fix, splitMessagesByTokenShare keeps msg1 (assistant) and msg2 (toolResult with ~750 tokens) together in chunk 1. Chunk 2 only contains msg3 (user). When chunk 1 is dropped, both messages are in droppedMessagesList, so:

    droppedMessages = 2
    droppedMessagesList.length = 2
    

    The assertion expect(pruned.droppedMessages).toBeGreaterThan(pruned.droppedMessagesList.length) evaluates to 2 > 2 → fails.

    Test 2 — "removes multiple orphaned tool_results from the same dropped tool_use" (lines 279–319):

    Similarly, the two toolResult messages ("result_a" / "result_b", each only a few tokens) are now kept in the same chunk as their assistant. All three are dropped together, so:

    droppedMessages = 3
    droppedMessagesList.length = 3
    

    The assertion expect(pruned.droppedMessages).toBe(pruned.droppedMessagesList.length + 2) evaluates to 3 === 5 → fails.

    The tests should be updated to match the new correct behavior (no orphaned tool_results from splitting, so droppedMessages === droppedMessagesList.length in both cases).

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: src/agents/compaction.test.ts
    Line: 218-250
    
    Comment:
    **Existing tests broken by the new split behavior**
    
    Two existing `pruneHistoryForContextShare` tests will fail after this change because their assertions are built around the OLD behavior where `splitMessagesByTokenShare` could land between a `tool_use` and its `toolResult`.
    
    **Test 1 — "removes orphaned tool_result messages when tool_use is dropped"** (lines 218–250):
    
    With the new fix, `splitMessagesByTokenShare` keeps `msg1` (assistant) and `msg2` (toolResult with ~750 tokens) together in chunk 1. Chunk 2 only contains `msg3` (user). When chunk 1 is dropped, both messages are in `droppedMessagesList`, so:
    ```
    droppedMessages = 2
    droppedMessagesList.length = 2
    ```
    The assertion `expect(pruned.droppedMessages).toBeGreaterThan(pruned.droppedMessagesList.length)` evaluates to `2 > 2` → **fails**.
    
    **Test 2 — "removes multiple orphaned tool_results from the same dropped tool_use"** (lines 279–319):
    
    Similarly, the two `toolResult` messages (`"result_a"` / `"result_b"`, each only a few tokens) are now kept in the same chunk as their assistant. All three are dropped together, so:
    ```
    droppedMessages = 3
    droppedMessagesList.length = 3
    ```
    The assertion `expect(pruned.droppedMessages).toBe(pruned.droppedMessagesList.length + 2)` evaluates to `3 === 5` → **fails**.
    
    The tests should be updated to match the new correct behavior (no orphaned tool_results from splitting, so `droppedMessages === droppedMessagesList.length` in both cases).
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/agents/compaction.test.ts
Line: 218-250

Comment:
**Existing tests broken by the new split behavior**

Two existing `pruneHistoryForContextShare` tests will fail after this change because their assertions are built around the OLD behavior where `splitMessagesByTokenShare` could land between a `tool_use` and its `toolResult`.

**Test 1 — "removes orphaned tool_result messages when tool_use is dropped"** (lines 218–250):

With the new fix, `splitMessagesByTokenShare` keeps `msg1` (assistant) and `msg2` (toolResult with ~750 tokens) together in chunk 1. Chunk 2 only contains `msg3` (user). When chunk 1 is dropped, both messages are in `droppedMessagesList`, so:
```
droppedMessages = 2
droppedMessagesList.length = 2
```
The assertion `expect(pruned.droppedMessages).toBeGreaterThan(pruned.droppedMessagesList.length)` evaluates to `2 > 2` → **fails**.

**Test 2 — "removes multiple orphaned tool_results from the same dropped tool_use"** (lines 279–319):

Similarly, the two `toolResult` messages (`"result_a"` / `"result_b"`, each only a few tokens) are now kept in the same chunk as their assistant. All three are dropped together, so:
```
droppedMessages = 3
droppedMessagesList.length = 3
```
The assertion `expect(pruned.droppedMessages).toBe(pruned.droppedMessagesList.length + 2)` evaluates to `3 === 5` → **fails**.

The tests should be updated to match the new correct behavior (no orphaned tool_results from splitting, so `droppedMessages === droppedMessagesList.length` in both cases).

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/agents/compaction.ts
Line: 159-163

Comment:
**`pendingToolCallIds` overwritten rather than accumulated across nested assistant turns**

When an `assistant` message with tool calls is encountered, `pendingToolCallIds` is replaced wholesale with the new set:

```ts
pendingToolCallIds = new Set(toolCalls.map((t) => t.id));
```

This is correct for normal alternating conversations, but consider a malformed (yet possible) history where a second assistant message appears while previous IDs are still pending. The old IDs are silently discarded, making the split-deferral guard permanently stale for those IDs. Adding an explicit `else` branch would make the "assistant without tool calls resets pending tracking" invariant clear:

```suggestion
      if (toolCalls.length > 0) {
        pendingToolCallIds = new Set(toolCalls.map((t) => t.id));
      } else {
        // No tool calls in this assistant turn — clear any stale pending state.
        pendingToolCallIds = new Set();
      }
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(compaction): keep tool_use and toolR..." | Re-trigger Greptile

Comment thread src/agents/compaction.ts Resolved
@openperf
openperf force-pushed the fix/compaction-tool-use-split branch from 613eb05 to 123ebe6 Compare April 1, 2026 08:30
@openperf

openperf commented Apr 1, 2026

Copy link
Copy Markdown
Member Author

🔒 Aisle Security Analysis

We found 1 potential security issue(s) in this PR:

Severity Title

1 🟡 Medium Potential denial of service in history pruning due to stuck pending tool call IDs preventing chunk splits

  1. 🟡 Potential denial of service in history pruning due to stuck pending tool call IDs preventing chunk splits
    Property Value
    Severity Medium
    CWE CWE-400
    Location src/agents/compaction.ts:139-176

Description

splitMessagesByTokenShare() now defers chunk boundaries while pendingToolCallIds.size > 0. If a toolResult message is missing a usable ID (toolCallId/toolUseId), the pending set is never cleared, and subsequent toolResult messages will keep the set non-empty.

Impact:

  • Chunk splitting can be suppressed for the remainder of the message stream after an assistant tool call.
  • In pruneHistoryForContextShare(), this can cause splitMessagesByTokenShare() to return a single chunk (chunks.length <= 1), making the pruning loop break while the token budget is still exceeded, leaving an oversized history.
  • Oversized histories can lead to excessive CPU/memory usage (token estimation/summarization work) and/or downstream provider API failures when too much context is sent.

This is triggered by malformed or unexpected transcripts where toolResult IDs are absent/empty (or otherwise not extractable by extractToolResultId).

Vulnerable code:

} else if (message.role === "toolResult" && pendingToolCallIds.size > 0) {
  const resultId = extractToolResultId(message);
  if (resultId) {
    pendingToolCallIds.delete(resultId);
  }
}

Recommendation

Add an escape hatch so chunk splitting/pruning cannot be blocked indefinitely by missing/malformed toolResult IDs.

Options (can be combined):

  • Clear pending state on unidentifiable toolResult (conservative): if a toolResult arrives without an ID, treat it as ending the pending sequence.
  • Bound the deferral window: clear pending after N messages or when currentTokens exceeds a hard cap.
  • Fail-safe in pruneHistoryForContextShare(): if chunks.length <= 1 while over budget, fall back to chunkMessagesByMaxTokens() and drop the earliest chunk.

Example fix (clear on missing ID + hard cap):

const MAX_DEFER_TOKENS = targetTokens * 2; // or a constant
...
} else if (message.role === "toolResult" && pendingToolCallIds.size > 0) {
  const resultId = extractToolResultId(message);
  if (!resultId) {
    pendingToolCallIds.clear();
  } else {
    pendingToolCallIds.delete(resultId);
  }
}
if (pendingToolCallIds.size > 0 && currentTokens > MAX_DEFER_TOKENS) {
  pendingToolCallIds.clear();
}

This preserves the intended invariant (don’t split between tool_use and its results) while preventing unbounded growth when transcripts are malformed.

Analyzed PR: #58849 at commit 123ebe6

Last updated on: 2026-04-01T08:32:58Z

The pendingToolCallIds Set only exists for the duration of the synchronous splitMessagesByTokenShare call. It processes a bounded array of messages already constrained by maxContextTokens and estimateMessagesTokens. The number of tool calls per assistant turn is also bounded by the LLM provider's output token limit. There is no persistence across requests, no database storage, and no accumulation over time. This does not constitute a memory growth or DoS vector.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 123ebe6086

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/agents/compaction.ts Resolved
@openperf
openperf force-pushed the fix/compaction-tool-use-split branch from 123ebe6 to f533339 Compare April 1, 2026 08:52
@obviyus
obviyus force-pushed the fix/compaction-tool-use-split branch from f533339 to e272368 Compare April 4, 2026 16:26
@obviyus obviyus self-assigned this Apr 4, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e2723683f8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/compaction.ts Resolved

@obviyus obviyus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed latest changes; landing now.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a2831fee53

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/compaction.ts
Comment on lines +157 to +160
pendingToolCallIds =
stopReason === "aborted" || stopReason === "error"
? new Set()
: new Set(toolCalls.map((t) => t.id));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear stale pending tool-call IDs when results are missing

This still deadlocks splitting for incomplete non-aborted tool turns: if an assistant includes tool calls with stopReason like "toolUse"/"stop" but no matching toolResult is ever present (for example from a partially persisted turn), pendingToolCallIds never clears, so the split gate is disabled for the rest of the pass and splitMessagesByTokenShare can return a single chunk even when far over budget. pruneHistoryForContextShare then exits early on chunks.length <= 1, leaving oversized history unpruned. Fresh evidence in this patch is that pending IDs are only reset for "aborted"/"error", so unresolved non-aborted tool calls remain stuck.

Useful? React with 👍 / 👎.

@obviyus
obviyus force-pushed the fix/compaction-tool-use-split branch from a2831fe to 17a3539 Compare April 4, 2026 16:42

@obviyus obviyus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed latest changes; landing now.

@obviyus
obviyus merged commit 08992e1 into openclaw:main Apr 4, 2026
8 checks passed
@obviyus

obviyus commented Apr 4, 2026

Copy link
Copy Markdown
Collaborator

Landed on main.

Thanks @openperf.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 17a3539cd4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/compaction.ts
Comment on lines +169 to +174
pendingToolCallIds.size === 0 &&
chunks.length < normalizedParts - 1 &&
currentTokens > targetTokens
) {
chunks.push(current);
current = [];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve a split point when toolResult is the final message

This post-toolResult split only runs after appending the result, so when the first over-budget point occurs on the last message of the list, the function can still return a single chunk. In transcripts like [older messages..., assistant(toolCall), toolResult] where currentTokens stays under target until that final toolResult, the pre-split at the loop top is blocked by pending tool IDs and this branch clears current at end-of-loop, leaving pruneHistoryForContextShare with chunks.length <= 1 and no way to drop over-budget older history.

Useful? React with 👍 / 👎.

lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…@openperf)

* fix(compaction): keep tool_use and toolResult together when splitting messages

* fix: keep displaced tool results in compaction chunks

* fix: keep tool calls paired during compaction (openclaw#58849) (thanks @openperf)

* fix: avoid stalled compaction splits on aborted tool calls (openclaw#58849) (thanks @openperf)

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…@openperf)

* fix(compaction): keep tool_use and toolResult together when splitting messages

* fix: keep displaced tool results in compaction chunks

* fix: keep tool calls paired during compaction (openclaw#58849) (thanks @openperf)

* fix: avoid stalled compaction splits on aborted tool calls (openclaw#58849) (thanks @openperf)

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…@openperf)

* fix(compaction): keep tool_use and toolResult together when splitting messages

* fix: keep displaced tool results in compaction chunks

* fix: keep tool calls paired during compaction (openclaw#58849) (thanks @openperf)

* fix: avoid stalled compaction splits on aborted tool calls (openclaw#58849) (thanks @openperf)

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
…@openperf)

* fix(compaction): keep tool_use and toolResult together when splitting messages

* fix: keep displaced tool results in compaction chunks

* fix: keep tool calls paired during compaction (openclaw#58849) (thanks @openperf)

* fix: avoid stalled compaction splits on aborted tool calls (openclaw#58849) (thanks @openperf)

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
…@openperf)

* fix(compaction): keep tool_use and toolResult together when splitting messages

* fix: keep displaced tool results in compaction chunks

* fix: keep tool calls paired during compaction (openclaw#58849) (thanks @openperf)

* fix: avoid stalled compaction splits on aborted tool calls (openclaw#58849) (thanks @openperf)

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request Sep 29, 2026
…@openperf)

* fix(compaction): keep tool_use and toolResult together when splitting messages

* fix: keep displaced tool results in compaction chunks

* fix: keep tool calls paired during compaction (openclaw#58849) (thanks @openperf)

* fix: avoid stalled compaction splits on aborted tool calls (openclaw#58849) (thanks @openperf)

---------

Co-authored-by: Ayaan Zaidi <[email protected]>
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
…@openperf)

* fix(compaction): keep tool_use and toolResult together when splitting messages

* fix: keep displaced tool results in compaction chunks

* fix: keep tool calls paired during compaction (openclaw#58849) (thanks @openperf)

* fix: avoid stalled compaction splits on aborted tool calls (openclaw#58849) (thanks @openperf)

---------

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 size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(compaction): splitMessagesByTokenShare can orphan tool_use from toolResult

2 participants