Skip to content

Commit 7d2dc7a

Browse files
committed
fix(agents): keep large read tool results visible
1 parent a2cbeef commit 7d2dc7a

3 files changed

Lines changed: 20 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ Docs: https://docs.openclaw.ai
129129
- Discord: keep REST, webhook, and monitor traffic on the configured proxy, preserve component-only media sends, honor `@everyone` and `@here` mention gates, keep ACK reactions on the active account, and split voice connect/playback timeouts so auto-join is more reliable. (#57465, #60361, #60345) Thanks @geekhuashan.
130130
- WhatsApp: restore `channels.whatsapp.blockStreaming` and reset watchdog timeouts after reconnect so quiet chats stop falling into reconnect loops. (#60007, #60069) Thanks @MonkeyLeeT and @mcaxtr.
131131
- Memory: keep `memory-core` builtin embedding registration on the already-registered path so selecting `memory-core` no longer recurses through plugin discovery and crashes during startup. (#61402) Thanks @ngutman.
132+
- Agents/tool results: keep larger `read` outputs visible on big-window models by raising the live tool-result ceiling instead of compacting normal file reads right after the first section. Thanks @vincentkoc.
132133
- Memory/QMD: prefer modern `qmd collection add --glob`, accept newer single-line JSON hit metadata while keeping legacy line fields, refresh QMD docs/doctor install guidance and model-override guidance, and keep older QMD releases working. Thanks @vincentkoc.
133134
- MS Teams: download inline DM images via Graph API and preserve channel reply threading in proactive fallback. (#52212, #55198) Thanks @Ted-developer and @hyojin.
134135
- MS Teams: replace the deprecated Teams SDK HttpPlugin stub with `httpServerAdapter` so recurring gateway deprecation warnings stop firing and the Express 5 compatibility workaround stays on the supported SDK path. (#60939) Thanks @coolramukaka-sys.

src/agents/pi-embedded-runner/tool-result-truncation.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ describe("calculateMaxToolResultChars", () => {
199199
});
200200

201201
it("exports the live cap through both constant names", () => {
202-
expect(DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS).toBe(40_000);
202+
expect(DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS).toBe(120_000);
203203
expect(HARD_MAX_TOOL_RESULT_CHARS).toBe(DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS);
204204
});
205205

@@ -212,6 +212,20 @@ describe("calculateMaxToolResultChars", () => {
212212
const result = calculateMaxToolResultChars(128_000);
213213
expect(result).toBe(DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS);
214214
});
215+
216+
it("keeps moderately large reads intact on 128K contexts", () => {
217+
const messages: AgentMessage[] = [
218+
makeUserMessage("hello"),
219+
makeAssistantMessage("reading changelog"),
220+
makeToolResult("x".repeat(60_000)),
221+
];
222+
const { messages: result, truncatedCount } = truncateOversizedToolResultsInMessages(
223+
messages,
224+
128_000,
225+
);
226+
expect(truncatedCount).toBe(0);
227+
expect(result).toEqual(messages);
228+
});
215229
});
216230

217231
describe("isOversizedToolResult", () => {

src/agents/pi-embedded-runner/tool-result-truncation.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ const MAX_TOOL_RESULT_CONTEXT_SHARE = 0.3;
1818
*
1919
* Pi already truncates tool results aggressively when serializing old history
2020
* for compaction summaries. For the live request path we keep a larger slice so
21-
* the model can still act on recent tool output, but we still want a bounded
22-
* request-local ceiling that cannot dominate the next turn.
21+
* the model can still act on recent tool output, especially large read results
22+
* on modern 128K+ context models, while still keeping a bounded request-local
23+
* ceiling that cannot dominate the next turn.
2324
*/
24-
export const DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS = 40_000;
25+
export const DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS = 120_000;
2526

2627
/**
2728
* Backwards-compatible alias for older call sites/tests.

0 commit comments

Comments
 (0)