Skip to content

fix(core): prepare complete structured-output requests - #3851

Merged
jujn merged 2 commits into
agentscope-ai:mainfrom
Buktal:codex/prepare-structured-output
Oct 31, 2026
Merged

jujn merged 2 commits into
agentscope-ai:mainfrom
Buktal:codex/prepare-structured-output

Conversation

@Buktal

@Buktal Buktal commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Structured-output reminders and a missing generate_response schema were added after final request preparation, so budget checks could inspect less than the actual provider request.

- prepare request -> append reminder/schema -> model
+ append reminder/schema -> prepare request -> model

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

  • Before: The primary path appended structured-output content after the request-preparation boundary.
    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.
  • Related regression tests and Spotless were rechecked after applying the change to current main (c4bab469c).
  • Full repository clean verify passed 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.

@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 6b16a78.

Approve preview

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
jujn merged commit 51a74e2 into agentscope-ai:main Oct 31, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants