Repository navigation
Description
Describe the bug
While integrating HarnessAgent 2.0.4 through AG-UI, I found two differences between the documented compaction/memory behavior and the implementation.
Evidence level: these findings come from source inspection. I have not executed a runtime reproduction or regression tests for either issue, and the reproduction steps below are proposed tests, not reported test results.
1. v2.0.4: streamEvents does not use the overflow recovery available to call
- wrappedCall adds onErrorResume and invokes recoverFromOverflow for recognized context-window errors.
- streamEvents delegates through wrappedStreamEvents, which manages resource acquisition/release but has no corresponding recovery branch.
- AguiAgentAdapter selects HarnessAgent.streamEvents, so the call-only fallback is not reached through that path.
Consequently, proactive threshold-based compaction can still work, but the emergency fallback appears unavailable when the provider actually rejects an AG-UI streaming request for context overflow.
Version distinction: v2.1.0-BETA1 already installs CompactionMiddleware.overflowRecovery(), which retries reasoning inside the execution when native Session Log is enabled. This part is therefore a 2.0.4 parity/backport question, not a claim that the newer EVENT_LOG path lacks recovery. Relevant change: a2cbea5 / #3441.
2. Custom MemoryConfig.flushPrompt is not propagated to pre-compaction memory extraction
In CompactionMiddleware.java, v2.0.4, onReasoning creates:
new MemoryFlushManager(workspaceManager, model)The two-argument constructor selects DEFAULT_FLUSH_PROMPT. In contrast, the per-call flush middleware receives the configured memoryConfig.flushPrompt().
The same two-argument construction is present in prepareCandidate in both v2.1.0-BETA1 and the locally available main snapshot d04529e99ed53faac9755d69241f5ee8af981652. I have not assumed that snapshot is the current remote HEAD.
This means project-specific extraction instructions appear to be ignored specifically during pre-compaction flush, even though extraction itself still runs.
To reproduce (proposed regression tests; not executed)
- Streaming recovery: configure compaction, seed enough history to allow a non-empty compacted prefix, and use a controllable model that rejects one main reasoning request with context_length_exceeded while allowing summarization and the retry. Compare call versus streamEvents / AG-UI on 2.0.4; check that recovery retries only the failed reasoning step and preserves valid lifecycle events.
- Prompt propagation: configure MemoryConfig.builder().flushPrompt("CUSTOM_FLUSH_MARKER ..."), enable flushBeforeCompact, set a small triggerMessages threshold and keepTokens(0), and capture the extraction model's input when pre-compaction flush occurs. Check that the custom prompt is used, as it is for per-call flush. Keep enough history outside the retained tail to actually trigger summarization.
Expected behavior
- Streaming and non-streaming execution should have equivalent emergency overflow recovery, or the version-specific limitation/backport recommendation should be documented.
- Pre-compaction extraction should receive the configured MemoryConfig.flushPrompt, consistent with per-call extraction.
The memory documentation states that per-call, pre-compaction, and overflow-triggered flush use the same configured flushPrompt. The context documentation describes overflow recovery in default EVENT_LOG mode.
Error messages
No runtime error log is attached because this report is based on source inspection. context_length_exceeded above is a proposed injected test condition, not an observed production log.
Environment
- Integration dependency: AgentScope Java 2.0.4
- Additional inspected sources: v2.1.0-BETA1 and main snapshot d04529e
- Java: 17.0.13
- OS: Windows
Could you confirm whether streaming recovery is intended to be backported to 2.0.x, and whether pre-compaction flush should receive the configured MemoryConfig prompt? Thank you.
Activity
fix(harness): preserve durable context through compaction (#3798)
juruoO-o commentedon Nov 12, 2026
Status update: #3798 (merged) preserves durable context through compaction. The v2.0.4 streaming overflow recovery and the custom flushPrompt propagation gaps noted here are separate and remain open.