agentscope-java icon indicating copy to clipboard operation
agentscope-java copied to clipboard

[Bug]: Snapshot overflow recovery drops structured output in HarnessAgent

Open kevinvv03 opened this issue 2 weeks ago • 0 comments

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

  1. Build a HarnessAgent with snapshot mode, a JsonFileAgentStateStore and compaction enabled.
  2. Populate the conversation with reducible history, such as 12 normal exchanges.
  3. Use a local Model fixture that reports context_length_exceeded for main requests until emergency summarization completes, then returns {"value":"ok"}.
  4. Call the agent with a structured output class containing a String value field, or an equivalent JsonNode schema.
  5. 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: 5a7e8e533709398fe5fc047e153235bfdf952498
  • 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.

kevinvv03 avatar Nov 17 '26 15:11 kevinvv03