Skip to content

fix(core): wire fallback model into ReActAgent - #1851

Merged
chickenlj merged 2 commits into
agentscope-ai:mainfrom
guslegend0510:fix/issue-1850-fallback-model
Jul 6, 2026
Merged

chickenlj merged 2 commits into
agentscope-ai:mainfrom
guslegend0510:fix/issue-1850-fallback-model

Conversation

@guslegend0510

@guslegend0510 guslegend0510 commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.0.0-SNAPSHOT

Related Issue

Fixes #1850

Description

This PR wires fallbackModel into ReActAgent's runtime model-call path. Before this change, fallback configuration was preserved in builder state but not actually used during execution, so the agent still failed when the primary model errored.

Changes

  • Use the configured fallback model when the primary model fails during model calls.
  • Preserve model resilience config (maxRetries, fallbackModel) in Builder.fromAgent(...).
  • Add regression tests for fallback switching and builder cloning.

Validation

  • mvn -pl agentscope-core "-Dtest=ReActAgentTest,ReActAgentNewLoopBuilderTest,ReActAgentGenerateOptionsTest" test

@guslegend0510
guslegend0510 requested a review from a team June 22, 2026 06:04
@codecov

codecov Bot commented Jun 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.78378% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...e/src/main/java/io/agentscope/core/ReActAgent.java 83.78% 3 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@AgentScopeJavaBot AgentScopeJavaBot added bug Something isn't working area/core/agent Agent runtime, pipeline, hooks, plan labels Jun 22, 2026

@AgentScopeJavaBot AgentScopeJavaBot 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.

🤖 AI Review

This PR fixes ReActAgent so that fallbackModel and maxRetries configurations actually take effect at runtime. The approach is correct: a modelForCall() decorator wraps the primary model with fallback logic, and buildGenerateOptions() injects maxRetries into ExecutionConfig. Two concerns: (1) the anonymous Model wrapper only overrides stream() and getModelName(), not supportsNativeStructuredOutput() or getContextWindowSize() - this violates the Decorator pattern contract; (2) summaryModelCallStream hook still references model.getModelName() (field) instead of mci.model().getModelName(), so fallback model name will not be reported correctly.

(inline comments could not be attached — line numbers fell outside PR hunks. See archived report.)

@chickenlj
chickenlj force-pushed the fix/issue-1850-fallback-model branch from f30432f to 6e0c382 Compare July 6, 2026 11:18
@chickenlj
chickenlj merged commit aea6f0a into agentscope-ai:main Jul 6, 2026
4 checks passed
zouyx pushed a commit to zouyx/agentscope-java that referenced this pull request Jul 6, 2026
wzl521 pushed a commit to wzl521/agentscope-java that referenced this pull request Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core/agent Agent runtime, pipeline, hooks, plan bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: The fallbackModel feature is not working.

4 participants