Repository navigation
Description
Describe the bug
With compaction enabled in snapshot mode (journalEnabled(false)), HarnessAgent can recover from context overflow and return a Msg, but lose the structured-output contract requested through call(input, Class<?>, ctx) or call(input, JsonNode, ctx). After recovery, hasStructuredData() returns false, even when the model returns valid JSON.
To Reproduce
- Build a HarnessAgent with snapshot mode, a JsonFileAgentStateStore and compaction enabled.
- Populate the conversation with reducible history, such as 12 normal exchanges.
- Use a local Model fixture that reports
context_length_exceededfor main requests until emergency summarization completes, then returns{"value":"ok"}. - Call the agent with a structured output class containing a String
valuefield, or an equivalent JsonNode schema. - Observe that emergency summarization runs and the call completes, but the returned Msg has no structured data.
The fixture simulates provider overflow. The 12 exchanges only provide reducible history; they do not represent a real provider's context limit.
Expected behavior
Successful overflow recovery should preserve the originally requested Class/schema. The returned Msg should contain structured data accessible through getStructuredData(...).
Error messages
The regression assertion fails for both structured-output overloads:
recovery must preserve structured output ==> expected: <true> but was: <false>
Both corresponding non-overflow controls pass.
Environment (please complete the following information):
- AgentScope-Java Version: 2.1.0-SNAPSHOT
- Base commit: 5a7e8e5
- Java Version: 21.0.11, compiling with release 17
- OS: macOS
Additional context
The initial call preserves Class/schema, but the snapshot recovery chain does not carry that information into forceCompactAndRetry. Its retry uses the plain delegate.call(retryInput, ctx) overload.
This report is limited to snapshot recovery. Native journal recovery is outside the confirmed affected path.
Related work includes #3661 and #3844. The former addresses compacted-state persistence and duplicate input. The latter changes overflow recovery and may affect which requests reach this path, but does not directly fix the Class/schema loss in this retry method.
Activity
fix(harness): preserve structured output during snapshot overflow rec…