Repository navigation
fix(core): prepare complete structured-output requests - #3851
Merged
Merged
Conversation
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
Buktal
added a commit
that referenced
this pull request
Oct 29, 2026
## Summary Reject unusable or non-reducing summaries before replacing conversation history. ```diff - collect summary text -> replace history + collect text, tool calls, and terminal status + reject output-limit responses, tool calls, and empty text + measure the wrapped summary plus retained tail with the configured estimator + replace history only when the complete candidate is strictly smaller ``` Rejected candidates retain successful lightweight reductions. Reuse the existing finish-reason interpretation from `ReasoningContext`; preserve model errors, cancellation, and the existing history-commit checks. Update the matching English and Chinese context documentation. Refs #3834 (slice 03). Structured-output preparation is tracked separately in #3851 and is not included here. ## Evidence - **Before:** A completed but larger summary, a response stopped at the output-token limit, or text mixed with tool calls could replace history. **After:** Local fake-model regressions reject those candidates, reject empty text, accept smaller valid summaries, and retain lightweight reductions when replacement is rejected. Existing chained-summary and cancellation tests remain covered. - Related core/Harness verification and Spotless: **138 tests passed**, zero failures/errors. The six-module reactor completed successfully with `mvn -B -T1C -pl agentscope-harness -am verify` and the relevant test classes selected. - Full repository `clean verify` was attempted and **did not pass**: `GracefulShutdownTest$StateAndConfigTests.defaultConfig` expected a null shutdown timeout but observed `PT0.1S`, reproducing the previously recorded test-order/configuration failure. Shutdown implementation and tests are unchanged. The attempt excluded only two local, uncommitted structured-output test classes already belonging to #3851; neither class is part of this PR. The shutdown test was not excluded or modified. - Documentation: **13 tests passed** and `npm run validate` passed. The existing broken-link check reports 2,222 issues; this change adds no links. - Checks ran on base `c4bab469c` with Java 21 and the project's Java 17 target. ## Merge Danger **Door:** Two-way. Reversible behavior change; no configuration or serialized-state migration. **Blast Radius:** Conversation. Automatic compaction now preserves existing history when a summary is unusable or fails to reduce the full candidate; the existing final request budget check still decides whether the request can proceed.
jujn
approved these changes
Oct 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Structured-output reminders and a missing
generate_responseschema were added after final request preparation, so budget checks could inspect less than the actual provider request.Use the preparer's returned messages, tools, and options directly. Keep reminders request-local so history compaction can still commit; preserve the existing no-preparer message format and empty metadata. Update the matching English and Chinese documentation.
Evidence
After: Capturing fake models verify call/stream, native/tool output, fallback re-preparation, and no duplicate reminders or schemas. Real Harness tests verify budget rejection before provider invocation and successful history compaction.
main(c4bab469c).clean verifypassed on the pre-refresh base (0ee781276): 99 modules, 11,322 tests passed, 243 skipped, zero failures/errors. The two intervening main commits are covered by the refreshed targeted checks; the full suite was not repeated after that base refresh.Merge Danger
Door: Two-way. Reversible code change, no public API or persistent schema changes.
Blast Radius: Requests. Tool-based structured output now participates in final request preparation; native output and requests without a preparer retain their existing behavior.
Refs #3834.