Skip to content

fix(gemini): honor default tool choice - #3858

Merged
jujn merged 1 commit into
agentscope-ai:mainfrom
Buktal:codex/gemini-default-tool-choice
Oct 30, 2026
Merged

jujn merged 1 commit into
agentscope-ai:mainfrom
Buktal:codex/gemini-default-tool-choice

Conversation

@Buktal

@Buktal Buktal commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

AgentScope-Java Version

2.1.0-SNAPSHOT

Description

Summary

Gemini ignored toolChoice in model defaults, although the equivalent per-call setting populated the provider request. Resolve the effective choice with the existing GenerateOptions.mergeOptions contract before applying the existing Gemini formatter.

- toolChoice = perCall.toolChoice
+ toolChoice = mergeOptions(perCall, defaults).toolChoice

Explicit per-call values retain priority. Add five request-config regression tests and matching EN/ZH documentation for default and per-call precedence.

Refs #3834 (slice 06). The shared tracking issue remains open for the other slices.

Evidence

  • Before: running the updated GeminiChatModelTest against the original implementation produces 3 errors: default Specific, default Specific with an unrelated per-call option, and default Specific with server tools all lack the expected function-calling configuration. The other 40 tests pass.
  • After: Gemini module tests pass (174 tests), including the 5 config scenarios: default/per-call equivalence, explicit None override, unset-field fallback, no tools, and server-tool coexistence. spotless:check passes.
  • Validation command: mvn -T1C -pl agentscope-extensions/agentscope-extensions-model/agentscope-extensions-model-gemini -am test spotless:check.
  • Documentation tests pass (13 tests); the local documentation checker passes for 432 pages and 584 redirects. Full mint validate is blocked locally by an EPERM while cleaning its shared preview directory. No live Gemini requests or full-repository clean verify were run.

Merge Danger

Door: two-way; reverting the commit restores the previous behavior.

Blast Radius: Gemini. Calls with function tools now honor a configured default tool choice; explicit per-call overrides remain effective.

Checklist

  • Code formatting verified with mvn spotless:check
  • Affected module and required upstream module tests pass (mvn -T1C -pl ... -am test)
  • Javadoc comments remain complete; no public API signatures added
  • Related EN/ZH documentation updated
  • Code is ready for review

@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 40d8bcd.

Approve preview

@jujn
jujn merged commit 4c35877 into agentscope-ai:main Oct 30, 2026
6 checks passed
chickenlj pushed a commit that referenced this pull request Nov 13, 2026
Apply effective per-call and builder-default tool choice through the
existing 2.0.x Gemini request path without changing explicit model names.

(cherry picked from commit 4c35877)
Constraint: No AgentScope Service or SDK migration
Confidence: high
Not-tested: Whole-repository verification pending after lane integration
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