Skip to content

feat(harness): preserve media messages in compaction and render placeholders in summaries - #3569

Open
dargoner wants to merge 2 commits into
agentscope-ai:mainfrom
dargoner:fix/compaction-media-semantics
Open

dargoner wants to merge 2 commits into
agentscope-ai:mainfrom
dargoner:fix/compaction-media-semantics

Conversation

@dargoner

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT (based on main @ 5f7f8e6)

Description

Background

Compaction did not treat media specially: messages that carry images/audio (base64 payloads or file references) could be silently dropped from the summarization input, and tool-result eviction could prune media-bearing blocks, leaving summaries and subsequent requests with dangling media references.

Changes

  • New media renderer and placeholder references (MediaReference, CompactionMediaRenderer): media blocks are extracted and replaced with stable placeholder tokens plus digest-based references, so summaries keep the semantic slot without shipping raw bytes to the summarization model.
  • Compaction preserves media messages (ConversationCompactor, CompactionConfig): messages carrying media are protected from summarization-dropping; the summarization input renders them as placeholders while the original messages stay in the retained tail.
  • Tool-result eviction skips media (ToolResultEvictionMiddleware): pruning skips media-bearing blocks (with redacted logs and failure paths) so eviction never creates dangling references.

Tests

  • CompactionMediaRendererTest (new): 11 cases.
  • ConversationCompactorTest 8 → 19, ToolResultEvictionMiddlewareTest 7 → 9.
  • Full agentscope-core (2630) + agentscope-harness (1269) suites: 0 failures (18 environment skips, same as baseline).
  • mvn spotless:check passes; docs (EN/ZH) updated and npm test / npm run check pass.

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

@dargoner
dargoner force-pushed the fix/compaction-media-semantics branch from 3ba92eb to 06acb88 Compare October 18, 2026 13:13
@dargoner
dargoner force-pushed the fix/compaction-media-semantics branch from 06acb88 to 06610b0 Compare October 29, 2026 11:59
@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 1eb60cc.

Approve preview

…semantics

# Conflicts:
#	agentscope-harness/src/main/java/io/agentscope/harness/agent/memory/compaction/ConversationCompactor.java
#	agentscope-harness/src/test/java/io/agentscope/harness/agent/memory/compaction/ConversationCompactorTest.java
#	docs/v2/en/docs/harness/context.md
#	docs/v2/zh/docs/harness/context.md
@jujn jujn added the P2 重要不紧急 label Nov 3, 2026

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

P2 重要不紧急

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants