Skip to content

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

Closed

Description

@kevinvv03

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: 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

  1. added
    bug
    on Nov 17, 2026
  2. added a commit that references this issue on Nov 18, 2026
    a3676aa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions