Skip to content

fix(gemini): route thinking config by model generation (#4220) - #4224

Merged
jujn merged 2 commits into
agentscope-ai:mainfrom
iluv7:fix/4220-gemini-4-thinking-config
Nov 17, 2026
Merged

jujn merged 2 commits into
agentscope-ai:mainfrom
iluv7:fix/4220-gemini-4-thinking-config

Conversation

@iluv7

@iluv7 iluv7 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT — based on main @ 5525ac1aa09e597042a259d581c51807e89bb0f5 (google-genai 2.2.0)

Description

Fixes #4220.

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test) — module tests and full mvn -B -T1C clean verify
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (N/A — Gemini thinking options were not previously documented)
  • Code is ready for review

…on invalid combos (agentscope-ai#4220)

Gemini 4 models (gemini-4-argon, gemini-4-carbon) use thinkingLevel instead
of thinkingBudget and reject thinking_budget outright. The adapter sent the
budget-era shape unconditionally whenever a budget was set, so requests
against Gemini 4 failed, zero budgets broke budget-era models, and thinking
could not be enabled on Gemini 4 at all.

- GenerateOptions: add tri-state includeThoughts and thinkingLevel options
- GeminiChatModel: model-aware thinking wiring (gate on argon/carbon),
  mirrored from agentscope-python PR agentscope-ai#3523/agentscope-ai#3675
- Fail fast with a clear error for budget on Gemini 4 / level on budget-era
  models / unsupported levels, instead of an opaque remote error
- Wire-level tests covering the mapping table, defaults merge, and
  stream-path fail-fast

Co-Authored-By: Claude Code <[email protected]>
@iluv7
iluv7 force-pushed the fix/4220-gemini-4-thinking-config branch from 029c50e to 101d4be Compare November 17, 2026 05:32
@iluv7

iluv7 commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

The Windows CI failure is unrelated to this PR — a flaky timing test in the RAG module:

DashScopeMultiModalEmbeddingTest.synchronousSdkCallRunsOffNonBlockingSubscriberThread
AssertionFailedError: The local server should receive the SDK request ==> expected: <true> but was: <false>

Details:

  • The test (agentscope-extensions-rag-simple, DashScopeMultiModalEmbeddingTest.java:217) waits 5s for the DashScope SDK to reach a local mock HTTP server and timed out at exactly that window on the Windows runner.
  • It does not touch GenerateOptions or any Gemini code — this PR only changes the Gemini thinking config path and adds fields to GenerateOptions.
  • The same suite passed on ubuntu-latest in this run, and a full mvn -B -T1C clean verify passes locally (macOS).

I've re-triggered CI. If it fails again on the same test, this looks like a pre-existing Windows-only flake worth a separate issue.

@jujn
jujn force-pushed the fix/4220-gemini-4-thinking-config branch from 101d4be to b1dedf5 Compare November 17, 2026 07:22
@mintlify

mintlify Bot commented Nov 17, 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 b1dedf5.

Approve preview

@jujn jujn changed the title fix(gemini): route thinking config by model generation and fail fast on invalid combos (#4220) fix(gemini): route thinking config by model generation (#4220) Nov 17, 2026

@jujn jujn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GeminiChatModel # applyThinkingConfig 写的太复杂了,以后每新增一个模型都要加一堆兜底代码;而且开发者在使用前会经过详细测试,测试中就会暴漏这些问题。做了简化只保留最重要的。

@jujn
jujn merged commit f0495f7 into agentscope-ai:main Nov 17, 2026
6 of 7 checks passed
@iluv7

iluv7 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

GeminiChatModel # applyThinkingConfig 写的太复杂了,以后每新增一个模型都要加一堆兜底代码;而且开发者在使用前会经过详细测试,测试中就会暴漏这些问题。做了简化只保留最重要的。

感谢 review, 我下次注意

xzxiaoshan added a commit that referenced this pull request Nov 20, 2026
…#4274)

## Background

Swept the last 125 PRs (#4272→#4075) for single-OS CI failures under
`mvn -B -T1C clean verify` (one build OS red, the other green on the
same commit = flake suspect). Cross-PR repeats and main's own red run on
2026-11-19 (ubuntu, run 44516464414) pinpoints four still-broken test
classes; all fixes are test-side only (no `src/main` changes).

## Fixes and evidence

| Test class | Victims | Signature | Fix |
|---|---|---|---|
| `RocketMqExecutionTest` | #4182, #4192, #4103 + main run 44516464414
(2026-11-19, ubuntu) | `turn reaches SUCCEEDED did not become true
within 10s` while the turn kept progressing (modelCalls complete, acks
climbing, lastFailure=none) — deadline breakthrough under starvation,
not a lost turn | shared `waitUntil` deadline 10s→30s (repo tier
#3726/#3774) |
| `AgentScopeAdapterTest` | #4204 (same-commit re-run green = confirmed
flake), #4191, #4246 | `Timed out observing Turn` at 6.7–8.5s elapsed;
resume/recovery one step from terminal | `turn.await(5s)`→30s at all 3
sibling sites via `TURN_DEADLINE`, outer `get` budgets +5s margin |
| `WorkerRuntimeTest` | #4219, #4224, #4255 (windows) | (a) `Worker
lease lost` after 2.4s — 1s claim leases expired between claim and
release; (b) `renewed.await(5s)` missed at 6.5s while the recovery lane
was healthy; (c) `Interrupted sleep interrupted` —
`WorkerRuntime.process()` interrupts the calling thread on lease-renewal
failure and manual `tick()` runs it on the test thread | (a) claim
leases 1s→30s (staleness under test still comes from `release(ZERO)` +
re-claim); (b) latches 5s→30s; (c) raw `Thread.sleep`→interrupt-proof
`pause()` at 5 sites, mirroring the #4176 fix for the same signature in
`ProcessRecoveryTest` |
| `ChatSessionsTest.await` (shared with `ChatControllerTest`) | #4233,
#4182 (stuck-RUNNING at 40.8s/46.4s), #4268, #4163 (poll threw `Durable
database transaction failed`) | two surfaces of one cause: every
snapshot poll opens a writing sqlite transaction contending with the
runtime's own writes, and windows runners starve turns past 30s (same
file already measured 56.6s starvation and uses 120s elsewhere, #3726) |
deadline 30s→120s (aligned tier) + tolerate transient `UNAVAILABLE`
store exceptions while polling; persistent failure rethrows at the
deadline, FAILED-turn fast-fail unchanged |
| `CommandExecutorTest.missingExitCodeIsUnknown` | local -T2C full-repo
stress (2026-11-19; pristine-main baseline of the same class green) |
the 2s network budget fired on scheduler starvation before the instant
fake response was processed, misclassifying the failure as a deadline
miss instead of a missing exit code (2.97s elapsed) | budget 2s→30s for
this non-deadline-semantics test; the two deadline-semantics tests keep
their tight budgets |

## Constraint compliance

- Happy path zero cost: every change only extends failure-path deadlines
or hardens helpers; no new sleeps, no weakened assertions.
- Minimal widening anchored to measured data (each comment cites victims
+ measured values); 30s follows the repo's established deflake tier,
120s follows this file's own previously measured starvation tier.
- Structural hardening preferred: `pause()` helper, transient-lock
retry, lease decoupling from the tested invariant.
- No `src/main` changes.

## Observed but deliberately not fixed here

-
`ProcessRecoveryTest.replacementCollectsOriginalResultWithoutRepeatingEffect`
(#4214: `expected: 2 but was: 3`): recovery-semantics race (model re-run
without effect re-run after abrupt halt) — a product question for the
durable recovery work, not a deadline flake.
-
`JevEvidenceProcessorTest.filterFailureIsWithheldButRankFailureFollowsScoredEvidence`
(#4265: delivered `[]` on a 25×-slowed runner): root cause not
established; single occurrence.
- Already fixed upstream, victims predate the fix:
`AgentScopeAgentExecutorInputRequiredTest` (#4157/#4187/#4152 all
predate #4176's `BaseReActAgentRunner` change), `InboxMiddlewareTest`
(#4093 predates #3738), `HarnessAgentSubagentStreamEventsTest` (#4183
predates #2917).
- `SkillBoxTest$UploadContainment` quartet (#4201/#4202/#4212/#4229):
test does not exist on main (fork stack only); deterministic cross-drive
path bug, not load flakiness.
- #4184/#4185: both-OS compile breaks from dependency major bumps
(dependabot), out of scope.

Also applied during review: sibling sites with the identical measured
mechanism were widened in the same pass — the remaining 1s fixture claim
leases in `WorkerRuntimeTest` (fenced begin/update/release sequences,
same #4219 signature), the start/PAUSED 5s budgets in the same
`AgentScopeAdapterTest` method as the victims, and the 5s/4s observe
budgets in
`completeLocalBackendRunsNativeAgentWhileManagedObserverIsBlocked`.

## Test plan

- [x] Full local `mvn -B -T2C clean verify` green (stricter than CI's
-T1C). Locally excluded, each verified to fail identically on pristine
main on this machine (Windows/git-bash) while passing on CI:
`JsonFileAgentStateStoreTest` (symlink permissions), the
`agentscope-extensions-durable-sandbox` trio plus
`ToolInSandboxExampleTest`/`SandboxRoundTripTest` (sandbox shell heredoc
incompatible with local git-bash python3), and the
`AgentScopeAdapterTest`/`ProcessRecoveryTest`/`HarnessExternalToolProcessRecoveryTest`
trio (durable-adapter classes whose Windows runs are skipped on CI; the
same named tests fail on pristine main locally).
- [ ] CI green on both OS.
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.

[Bug]: Gemini thinkingConfig breaks Gemini 4 models — thinkingBudget sent unconditionally, no model gate

2 participants