feat(event): emit COMPACTION_START/END events from CompactionMiddleware#1962
Open
Buktal wants to merge 2 commits into
Open
feat(event): emit COMPACTION_START/END events from CompactionMiddleware#1962Buktal wants to merge 2 commits into
Buktal wants to merge 2 commits into
Conversation
When context compaction is triggered, CompactionMiddleware now emits COMPACTION_START before the summarization LLM call and COMPACTION_END after reasoning completes, allowing frontends to display progress instead of appearing frozen. Events carry token statistics so callers can show meaningful progress information. Closes agentscope-ai#1905
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…ent and CompactionMiddleware - CompactionEventRoundTrip in AgentEventStreamTest: JSON serialization/deserialization round-trip via Jackson polymorphism for both compaction event types; field values and type discriminator are verified - CompactionMiddlewareTest: covers the four execution paths — no compaction (passthrough), compaction triggered (START/END wrap next flux), non-ReActAgent short-circuit, and compaction error fallback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentScope-Java Version
2.0.0-SNAPSHOT
Description
Fixes #1905.
Background: When
CompactionMiddlewaretriggers context compaction (a summarization LLM call), the frontend receives no events during this period and appears frozen.Changes:
COMPACTION_STARTandCOMPACTION_ENDtoAgentEventTypeCompactionStartEvent(carriesestimatedTokens,triggerThreshold) andCompactionEndEvent(carriesoriginalMessageCount,compactedMessageCount,estimatedTokensSaved)AgentEvent@JsonSubTypesCompactionMiddleware.onReasoning()wraps the reasoning stream withCOMPACTION_START→ stream →COMPACTION_ENDwhen compaction is actually triggered (events are not emitted when the token threshold is not reached)Testing: Full build passes (
mvn clean install). The events fire only when compaction triggers, consistent with the existing event model (e.g.MODEL_CALL_START/END).Checklist
mvn spotless:applymvn test)