Skip to content

fix(harness): preserve rich tool results during compaction - #3845

Open
Buktal wants to merge 1 commit into
agentscope-ai:mainfrom
Buktal:codex/preserve-rich-tool-results
Open

Buktal wants to merge 1 commit into
agentscope-ai:mainfrom
Buktal:codex/preserve-rich-tool-results

Conversation

@Buktal

@Buktal Buktal commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

AgentScope-Java Version

2.1.0-SNAPSHOT

Description

Refs #3834 — slice 01 of 09. The shared tracking issue remains open for the remaining slices.

Pruning or offloading a long tool result currently rebuilds its entire output as one text block, losing images, audio, and other non-text blocks. Pruning also drops producer-supplied execution details.

Summary

Tool output: [long head text] [image/audio] [long tail text]

Before:      [head ... tail + optional recovery path]
After:       [head ...] [same image/audio] [tail]

Use one shared ToolResultPreview implementation for pruning and offloading. Apply a single text allowance across all text blocks, preserve non-text order and result/message fields, and omit a marker when no text was removed. String previews used for summary input delegate to the same implementation.

Offloading still saves complete text through the configured Filesystem and RuntimeContext. Cached text replacements rebuild each view from its own media blocks; failed writes retain the original result. Update EN/ZH context documentation.

Evidence

  • Before: mixed-media fixtures lose their non-text blocks; pruning loses executionDetails. The initial regression run had 7 failures and 1 error across 21 cases. An additional full-preview boundary test reproduced an omission marker being inserted even when no text was removed.
    After: all 32 targeted cases pass, covering media order, shared text allowances, result/message fields, canonical/hook views, filesystem readback, failed writes, zero/full previews, whitespace, and the summary's 600-character boundary.
mvn -B -T1C -pl agentscope-harness -am '-Dtest=ConversationCompactorPruneTest,ToolResultEvictionMiddlewareTest,ConversationCompactorSummaryShapeTest' test
mvn -B -T1C clean verify
  • Full verification: 99 modules pass; 11,324 tests pass, 243 are skipped; zero failures/errors. Includes Spotless. Targeted tests have no skips.
  • Documentation: npm test passes 13 tests; npm run validate passes, including the repository's check of 432 pages and 584 redirects. mint broken-links reports 2,218 links in 326 files; this PR changes no documentation links or anchors, and the discrepancy with the repository checker remains unresolved.
  • Source precedents: DSH block-wise text pruning and ZCode media protection.

Merge Danger

Door: two-way — no migration or serialized-state change.

Blast Radius: Harness — tool-result text previews in compaction/offloading and summary-input formatting. Character accounting keeps Java's existing UTF-16 units. Provider-specific media support continues to use the existing converters; no live E2B/Docker/Kubernetes compatibility claim is made.

Checklist

  • Code has been formatted with mvn spotless:apply.
  • Java tests pass (mvn -B -T1C clean verify; skips recorded above).
  • Javadoc comments follow project conventions.
  • Related EN/ZH documentation has been updated.
  • Code is ready for review.

@mintlify

mintlify Bot commented Oct 29, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 9fc7dc1.

Approve preview

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants