Skip to content

[Bug]: Preserve Harness model inputs across compaction and auxiliary calls #3834

Closed

Description

@Buktal

Describe the bug

This is a shared tracking issue for nine small PRs covering Harness model inputs, conversation reduction, auxiliary calls, and model options. Each PR should reference this issue; it should remain open while the remaining slices are pending.

The current input pipeline has several independent boundary problems. For example, pruning or offloading a tool result replaces its entire output with text, losing image/audio blocks. Other paths use different input accounting, accept incomplete auxiliary outputs, or lose effective model options.

To reproduce

The following observations were reproduced with local fixtures against 7653eb7ec8fd6763dc7af501355f4951b36632bf:

Path Observed Expected
Tool-result pruning and offloading A result containing one image contains zero images after either pass. Pruning also drops executionDetails. Shorten text while retaining rich blocks in order and preserving execution facts.
Compaction accounting The same media history is estimated at 138 tokens by the compaction path and 49,180 by the final input estimator; no summary is requested. Use the effective input estimator throughout the reduction decision.
Summary replacement A 38-token fixture can be replaced by a 1,350-token candidate, including a response stopped by the output limit. Commit a complete candidate only when the complete replacement reduces the request.
Structured-output preparation A fixture prepares 5 characters but sends 179 after adding the structured-output reminder. Assemble the reminder and required schema before final preparation.
Memory consolidation An output-limit response overwrites the existing memory and advances progress. Retain the prior memory/progress when consolidation is incomplete.
Gemini tool choice A default specific-tool setting produces no toolConfig; the equivalent per-call setting does. Resolve the effective setting consistently.
Ollama execution options Conversion drops a per-call execution config; a delayed 150 ms fake response succeeds despite a 20 ms timeout. Carry execution options into the actual call.
Windows session reads Reading five objects through the outer storage opens five JDBC connections; the existing SQLite batch implementation opens one. Delegate the outer batch operation to the existing implementation.

These are offline correctness fixtures, not model-quality or production-latency benchmarks. The subagent prompt slice below follows the existing lifecycle and delivery implementation rather than a benchmark.

Planned PRs

  • 01 — Preserve rich tool results during pruning/offloading. Share text preview handling, retain non-text order and execution facts, and preserve filesystem recovery and write-failure behavior. PR: #3845. Ready for review; completion remains pending merge and verification.
  • 02 — Align compaction with final input accounting. Pass the effective estimator through compaction triggering, tail selection, and final checks. PR: #3847. Ready for review; completion remains pending merge and verification.
  • 03 — Validate summary candidates before replacing history. Reject incomplete or non-reducing candidates. Depends on 02.
  • 04 — Prepare complete structured-output requests. Include primary-call reminders and required schemas before final input checks.
  • 05 — Commit only complete memory consolidation. Use the auxiliary input boundary and advance memory/progress only on a valid complete response.
  • 06 — Honor effective Gemini tool choice. Align default and per-call option resolution.
  • 07 — Preserve Ollama per-call execution options. Carry timeout/retry settings through conversion.
  • 08 — Align subagent prompt wording with runtime behavior. Describe independent sessions, invocation results, follow-up support, and result visibility accurately.
  • 09 — Delegate Windows session batch reads. Reuse SQLite batching while retaining path checks and replay behavior.

Only 02 → 03 is a technical dependency. This issue tracks completion after each slice is merged and verified; publishing PR 01 does not complete the overall effort. Future PRs should reference this issue without automatically closing it.

Expected behavior

Each PR should provide its own regression coverage and matching EN/ZH documentation when behavior changes. Preserve public builders, tool-call/result associations, execution state, session/user isolation, cancellation, permission checks, and the configured workspace/storage abstractions. The changes must work with local or server-hosted Harness deployments.

Already merged sandbox-root guidance and Anthropic error-state fixes are excluded. Gemini tool-media endpoint compatibility, parent-context inheritance policy, spec-generation input policy, and prompt-quality experiments require separate evidence/contract decisions and are outside these nine slices.

Environment

  • AgentScope Java: 2.1.0-SNAPSHOT, baseline 7653eb7ec8fd6763dc7af501355f4951b36632bf.
  • Java: 21, with the project's Java 17 target.
  • OS: Windows 11; the batching observation is specific to the Windows storage delegation path.

Implementation references

For slice 01, DeepSeek Harness's block-wise text pruner retains non-text order, while ZCode protects media-bearing results from clearing. AgentScope Java can retain media while shortening text through its existing compaction and workspace-filesystem paths.

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