Skip to content

fix(harness): bound arbitrary tool outputs and recover context overflow - #3844

Open
wzq-xzwj wants to merge 1 commit into
agentscope-ai:mainfrom
wzq-xzwj:fix/harness-tool-result-budget
Open

wzq-xzwj wants to merge 1 commit into
agentscope-ai:mainfrom
wzq-xzwj:fix/harness-tool-result-budget

Conversation

@wzq-xzwj

@wzq-xzwj wzq-xzwj commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem and change

Closes #3843. An arbitrary tool result can exceed the complete request budget even when normal result eviction is disabled, the tool is excluded, storage fails, or the output is below the ordinary eviction threshold. The next request then fails, and the retained oversized result can obstruct continuation.

Add deterministic output reduction at the final model boundary, before either reasoning or summarization. Preserve tool-call identity/state/metadata, archive full output blocks as JSON when possible, and disclose unavailable content when storage cannot preserve it. Commit the bounded canonical history only after final validation. On a provider context rejection, attempt a reduced tool-result view and retry once in both native and legacy session modes. If forced summarization is needed, retain the current user turn and tool exchanges. No tool is rerun by recovery.

This complements read_file pagination in #3821; it does not depend on tools implementing their own size limits. EN/ZH context documentation describes the behavior and limits.

Validation

  • Latest unpatched main 7653eb7e: all 10 new regression scenarios fail.
  • Patched Harness module: 1,471 tests, 0 failures/errors, 33 skipped; Spotless and install pass.
  • Coverage includes excluded read_file, arbitrary results below the eviction threshold, disabled eviction, denied storage, known/unknown windows, call/streamEvents, next messages, and file-backed agent recreation with native/legacy history.
  • Benben adaptation: 110 backend tests pass against the source-built snapshot; browser artifact readback and continuation covered.
  • Full clean verify was attempted: Core ran 2,857 tests with 0 assertion failures, 2 errors and 9 skipped. The two errors are unchanged DangerousPathBypassTest symlink fixtures denied by Windows privileges; downstream modules skipped by this reactor are not claimed as verified. The separate Harness suite above passed.
  • Documentation: 13 local tests, static checks (432 pages/584 redirects), and Mintlify build validation pass. The whole-site broken-link scan reports 2,218 links in 326 files; these were not individually baseline-attributed. This patch adds no documentation links. Remote docs validation, license and module sync checks pass.
  • Remote Windows CI currently fails in unchanged Channel Common IdempotencyStoreTest.entriesExpireAfterTtl (80 ms TTL timing assertion). No Channel Common/Core source changes are included. A rerun requires upstream administrator permissions (API 403). Ubuntu CI passed.

Boundaries

Storage failure causes an explicit lossy fallback. Fixed prompts, user input, schemas or irreducible metadata can still exceed the model budget. One provider retry cannot guarantee recovery for arbitrary tokenizers or unknown limits. This does not cap allocations inside tools, migrate legacy sessions, or claim live-provider validation.

@mintlify

mintlify Bot commented Oct 29, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 6667b91.

Approve preview

@wzq-xzwj
wzq-xzwj marked this pull request as ready for review October 29, 2026 01:04
@jujn jujn added the P2 重要不紧急 label Nov 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 重要不紧急

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Oversized arbitrary tool results can defeat Harness compaction and session recovery

2 participants