Skip to content

feat: deterministic tool-result clearing at send time - #1313

Open
SK-DEV-AI wants to merge 4 commits into
1jehuang:masterfrom
SK-DEV-AI:feat/tool-result-clearing
Open

SK-DEV-AI wants to merge 4 commits into
1jehuang:masterfrom
SK-DEV-AI:feat/tool-result-clearing

Conversation

@SK-DEV-AI

Copy link
Copy Markdown

Closes #1217 as built (design agreed in thread; opening the code for review rather than waiting on another gate round).

When clear_tool_results_older_than=N, tool results older than the last N provider-bound messages are stubbed at send time. ToolUse blocks (name + input) and result IDs are always kept so provider tool-pairing never breaks; results under 200 chars are left alone. Session file untouched (send view only), so later compaction still summarizes full history. Off when unset.

Tests: 18 clearing tests through fmt, clippy, full-suite stash comparison with isolated reruns (zero regressions). Re-fetch cost is inherent (tool outputs are not pure functions), documented in #1217.

@greptile-apps

greptile-apps Bot commented Sep 19, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

Safe to merge; no blocking issues remain.

Summary

This change adds configurable clearing of older tool results while preserving complete session history and provider tool-pairing metadata. It now retains user-uploaded images and applies textual retention limits using character counts.

Reviews (4) · Last reviewed commit: "fix(review): clear only tool-message ima..."

Comment thread crates/jcode-app-core/src/agent.rs
@greptile-apps

This comment has been minimized.

@github-actions github-actions Bot added area: config Configuration, defaults, and environment overrides. type: feature Adds a new user-facing capability. labels Sep 19, 2026
A 100-CJK-char result is 300 bytes; the byte-length check stubbed it
under a 200-char policy and reported a byte count as chars. Both the
threshold and the reported count use chars now. Regression test with
100-char (survives) and 300-char (stubs as 300 chars) CJK payloads.
@greptile-apps

greptile-apps Bot commented Sep 19, 2026

Copy link
Copy Markdown

Want your agent to iterate on Greptile's feedback? Try greploops.

Research pass (Anthropic context engineering: tool payloads are
artifacts, only facts matter): tool-returned images ride in the same
message as the ToolResult as base64, often 100KB-1MB each — the
largest context hog, and the old code stubbed the text while leaving
them intact. Past-cutoff Image blocks now become text placeholders
(media type plus size); pairing IDs untouched, recent images kept,
session file keeps full history.
Comment thread crates/jcode-app-core/src/agent.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: config Configuration, defaults, and environment overrides. type: feature Adds a new user-facing capability.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proactive tool-result clearing (deterministic, send-view only)

1 participant