Skip to content

fix(core): drop merge residue from the structured-output fallback branch - #1

Closed
wahllllll wants to merge 1 commit into
xzxiaoshan:fix/structured-output-fallbackfrom
wahllllll:fix/structured-output-merge-residue
Closed

wahllllll wants to merge 1 commit into
xzxiaoshan:fix/structured-output-fallbackfrom
wahllllll:fix/structured-output-merge-residue

Conversation

@wahllllll

@wahllllll wahllllll commented Oct 10, 2026 •

Copy link
Copy Markdown

What this is

Follow-up to agentscope-ai#2697. I reviewed the branch and found three leftovers from the merge of main — all cosmetic, but two of them are the kind of thing that makes the next reviewer stop and re-derive intent. I fixed them here rather than only commenting, so you can take the commit as-is if you agree.

Branch: wahllllll:fix/structured-output-merge-residue, three files, +7 / −5, no production behaviour change.

The three cleanups

1. ReActAgent.Builder.copy() assigned copy.agentId twice (agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java)

             copy.name = this.name;
             copy.agentId = this.agentId;
             copy.description = this.description;
-            copy.agentId = this.agentId;
             copy.sysPrompt = this.sysPrompt;

main has exactly one copy.agentId line. The setters are idempotent so nothing changes at runtime, but the duplicate sits after copy.description, so at a glance it reads as if a field between the two lines was being re-wired.

2. HarnessAgentIdTest chained legacySessionHistory(true) twice (agentscope-harness/src/test/java/io/agentscope/harness/agent/HarnessAgentIdTest.java)

                         .legacySessionHistory(true)
                         .model(stubModel())
                         .workspace(workspace)
-                        .legacySessionHistory(true)
                         .build();

Both fixtures, same shape. After the fix the file is byte-identical to main and drops out of agentscope-ai#2697's diff entirely — which also answers the "why is this file in a structured-output PR" question for free.

3. MockModel's javadoc defends its default with the assumption this branch drops (agentscope-core/src/test/java/io/agentscope/core/agent/test/MockModel.java)

The comment read:

Defaults to true since most models support it; only the few providers that don't override it to false.

Two things are off now. "Most models support it" is precisely the assumption this branch drops when it flips the interface default to false, so the only reason a reader is given for the mock returning true is the claim the branch just rejected — the reader has no way to tell that the mock is deliberately diverging. And it calls a test mock a "provider". Rewritten to state what the mock actually does and to point at setSupportsToolChoiceSpecific(...) for opting out.

Four things I did not change

These are judgement calls on your design, not defects I should be editing under you. Details and evidence are in my review comment on agentscope-ai#2697; short version:

  • Model.supportsToolChoiceSpecific() default flipped true → false in 4fe0e54f. That is the right instinct (never assume a named tool_choice on an unknown endpoint) but it silently moves every OpenAI-compatible deployment pointed at a self-hosted or gateway URL — vLLM, internal gateways, direct Moonshot — off the hard constraint and onto the prompt reminder. For those users the hard constraint was the reliability this PR adds. Worth an explicit migration note and a release-notes line.
  • For supportsToolChoiceSpecific() == false models the forced retry cannot escalate. The reminder text is regenerated identically each round and the hard constraint is gated on soForceToolChoiceCount > 0, so rounds 2 and 3 only re-append the model's own rejected answer. Your own testStructuredOutputPromptReminderPresentOnEveryFallbackRound asserts List.of(1, 1, 1) — same count every round. The three-round budget is real; the pressure is not.
  • Rejected free-text answers go into state.contextMutable() (the eventMsg add runs before the isFinished check), so up to three rejected answers persist — unlike the deliberately transient reminder right next to them.
  • KimiModelProvider's nativeStructuredOutput flipped false → true. Unlike the other three this one is not a defect — you updated the class javadoc in step, so it is deliberate. It is just the one change in 4fe0e54f that has nothing to do with tool_choice, and it changes which path Kimi takes, so it deserves its own line in the release notes rather than riding along inside a tool_choice fix.

Verification

mvn -o -pl agentscope-core,agentscope-harness -am spotless:check test \
  -Dtest='ReActAgentStructuredOutputTest,HarnessAgentIdTest'

BUILD SUCCESS, MVN_EXIT=0. ReActAgentStructuredOutputTest: 13 run, 0 failures, 0 errors, 1 skipped. HarnessAgentIdTest: 1 run, 0 failures. Spotless clean on both modules.

Your 3421ac5 merge of main does not change any of this — I re-read all three files at that revision and the counts are unchanged (copy.agentId ×2, .legacySessionHistory(true) ×5). This PR is still MERGEABLE against your branch.

Take it, cherry-pick it, or ignore it — the review comment stands on its own.

Three leftovers from merging main, none of them intentional:

- ReActAgent.Builder.copy() assigned copy.agentId twice, the second one
  after copy.description. Builder setters are idempotent so behaviour is
  unchanged, but the method no longer matched main and the extra line
  reads as if two different fields were being wired.
- HarnessAgentIdTest chained legacySessionHistory(true) twice in the same
  builder call, in both fixtures. Harmless, but that file belongs to the
  agentId change, not to a structured-output fix.
- MockModel's javadoc for supportsToolChoiceSpecific justified its true
  default with "since most models support it; only the few providers that
  don't override it to false". That rationale is the one this branch
  reverses when it flips the interface default to false, and it calls a
  test mock a "provider". Reworded to say what the mock does and to point
  at setSupportsToolChoiceSpecific for opting out.

No production behaviour change.
@wahllllll
wahllllll force-pushed the fix/structured-output-merge-residue branch from 15f090f to 8184a65 Compare October 10, 2026 07:00
@wahllllll

Copy link
Copy Markdown
Author

Closing this — you did the same cleanup yourself in bfbd0bc73, and it landed cleaner than mine.

I checked the three files at your head:

file vs my branch
ReActAgent.java byte-identical
HarnessAgentIdTest.java byte-identical
MockModel.java javadoc wording only — yours is tighter and says the same thing

So there is nothing left to merge here, and a conflicting PR sitting in your fork is just noise. bfbd0bc73 is the fix.

Note that the four review points in my comment on agentscope-ai#2697 are untouched by that commit, so they are still open for discussion there. The one I would most like a decision on is the supportsToolChoiceSpecific() default flip — the direction is right, but it moves self-hosted and gateway OpenAI-compatible endpoints off the hard tool_choice constraint, so it deserves a migration note and a release-notes line rather than passing silently.

@wahllllll wahllllll closed this Oct 10, 2026
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.

1 participant