Skip to content

fix(harness): render inbox notifications and failure reminders as framework messages in compaction summaries - #4566

Open
PHLIH wants to merge 1 commit into
agentscope-ai:mainfrom
PHLIH:fix/compaction-synthetic-aliases
Open

PHLIH wants to merge 1 commit into
agentscope-ai:mainfrom
PHLIH:fix/compaction-synthetic-aliases

Conversation

@PHLIH

@PHLIH PHLIH commented Dec 2, 2026

Copy link
Copy Markdown

AgentScope-Java Version

2.1.0-SNAPSHOT (main at 634fe8d)

Description

Fixes #4565.

The compaction summary transcript labelled framework-injected messages as Human: turns. renderMessageForSummary only recognised the canonical Msg.METADATA_SYNTHETIC key ("agentscope_synthetic"), while InboxMiddleware (background tool/hint notifications) and RepeatedFailureGuard (repeated failure reminders) mark their USER-role messages with the alias "synthetic". The summary prompt tells the summarizing model that Human: lines are the user's own words, so a notification shaped like

Automated background event from tool_output. This is context, not a user message or approval.

was promoted into the summary as a user request. The same file already read both keys in findLatestUserInput, and CompactionMiddleware.recoveryTailSize does as well; the label rendering was the one place that missed the alias.

Changes

  • ConversationCompactor: new METADATA_SYNTHETIC_ALIAS constant and a package-private isSyntheticMessage(Msg) helper that accepts the canonical key or the alias. renderMessageForSummary uses it to choose FrameworkMessage, and findLatestUserInput uses it instead of its inline duplicate of the same check.
  • ConversationCompactorSummaryShapeTest: new formatMessagesForSummaryLabelsLegacySyntheticKeyAsFrameworkMessages, built from the exact metadata shape InboxMiddleware.notification(...) writes ({"synthetic": true, "reminderKind": "background_event"}). It asserts the background event renders as FrameworkMessage: and that no Human: Automated background event line appears, while genuine user speech keeps the Human: label.

No public API change; nothing changes for messages that already carry Msg.METADATA_SYNTHETIC.

Tests

mvn -pl agentscope-harness spotless:check                              -> BUILD SUCCESS
mvn -pl agentscope-harness test -Dtest='ConversationCompactor*Test,CompactionMiddlewareTest,InboxMiddlewareTest'
  -> Tests run: 93, Failures: 0, Errors: 0, Skipped: 0

The new test fails on the unmodified tree with

a message marked with the legacy synthetic key must not render as a Human turn:
Human: Automated background event from tool_output. This is context, not a user message or approval.

and passes with the change. The full agentscope-harness suite was not run in this environment; the modules needed by this change (agentscope-core, agentscope-harness) build with mvn -pl agentscope-harness -am -DskipTests install.

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test for the affected module and test classes)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.) — no documentation describes this label mapping, so none needed
  • Code is ready for review

@CLAassistant

CLAassistant commented Dec 2, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

[Bug]: Compaction summaries render inbox notifications and failure reminders as user speech

2 participants