Skip to content

fix(core): preserve failed summary termination state - #2757

Merged
zouyx merged 3 commits into
agentscope-ai:mainfrom
DennisWLX:codex/fix-2754-summary-failure-state
Sep 10, 2026
Merged

zouyx merged 3 commits into
agentscope-ai:mainfrom
DennisWLX:codex/fix-2754-summary-failure-state

Conversation

@DennisWLX

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.0.3-SNAPSHOT

Description

When the ReAct loop reaches maxIters and final summary generation also fails, the fallback message currently uses the default MODEL_STOP reason. Downstream callers cannot distinguish this failure from a normal model completion.

This change:

  • preserves GenerateReason.MAX_ITERATIONS on the summary fallback message
  • adds internal _summary_failed=true metadata for explicit failure detection
  • adds a regression test for the returned reason, metadata, and error text

Fixes #2754

Testing

  • mvn -pl agentscope-core clean test: 2276 tests passed, 9 skipped

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (metadata Javadoc; no external docs required)
  • Code is ready for review

Keep MAX_ITERATIONS as the generate reason when final summary generation fails, and expose the failure through message metadata for downstream callers.\n\nFixes agentscope-ai#2754
@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@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 adds metadata markers to the summary-error fallback path in ReActAgent.handleSummaryError(). Specifically, it sets SUMMARY_FAILED=true in the message metadata and explicitly assigns GenerateReason.MAX_ITERATIONS to the error fallback message. This brings the error path into symmetry with the successful summary path (which already sets MAX_ITERATIONS via withGenerateReason), while the new SUMMARY_FAILED flag allows callers to distinguish a failed summary from a successful one. The change is minimal, well-targeted, and includes a focused unit test that validates all three assertions (generate reason, metadata flag, and error message text). No bugs or correctness issues found.

+ " generating summary: %s",
maxIters, error.getMessage()))
.build())
.metadata(Map.of(MessageMetadataKeys.SUMMARY_FAILED, true))

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.

[nitpick] The .metadata(Map.of(...)) call creates an unmodifiable map. The subsequent .generateReason() call correctly wraps it into a HashMap (via the instanceof HashMap check in Msg.Builder.generateReason()), so the current code works correctly. However, this creates an implicit ordering dependency: if a future refactoring moves .metadata() after .generateReason(), the metadata() call would silently overwrite the generate-reason entry. Consider adding a brief comment like // .metadata() must precede .generateReason() or using new HashMap<>(Map.of(...)) directly to make the intent explicit and prevent accidental breakage.

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

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

有个冲突要解决下

@zouyx
zouyx merged commit 1e64818 into agentscope-ai:main Sep 10, 2026
5 checks passed
dargoner added a commit to dargoner/agentscope-java that referenced this pull request Sep 12, 2026
把本地流式文本处置分支与 PR 分支对齐,避免两条线各自漂移:

- AG-UI:最终快照排除的文本段改为按本轮实际启动的文本消息集合(startedTextMessages)判定,不再用消息 ID 正则反推,并同步适配器测试;

- harness:子代理结束前补发权威 AGENT_RESULT 事件,并补充事件顺序断言;

- core:补回上游 agentscope-ai#3010、agentscope-ai#2757 覆盖的不连续文本段唯一块 ID 与摘要失败终止状态用例(此前本地合并时遗漏)。
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.

[Feature]: Preserve max-iteration terminal semantics when summary generation fails

3 participants