Skip to content

fix(agent): detect model failures by marker, not answer text - #221

Merged
yuluo-yx merged 1 commit into
agentic-ai-java:mainfrom
Duansg:fix/agent-model-failure-flag
Oct 23, 2026
Merged

yuluo-yx merged 1 commit into
agentic-ai-java:mainfrom
Duansg:fix/agent-model-failure-flag

Conversation

@Duansg

@Duansg Duansg commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Describe what this PR does / why we need it

Contributing to ARGI: callResult/streamResult no longer report MODEL_FAILED for normal answers that happen to start with Exception: .

Does this pull request fix one issue?

Fixes #205

Describe how you did it

  • When throwOnModelError is disabled, AgentLlmNode marks its substituted failure message with framework metadata (AgentLlmNode.MODEL_FAILURE_METADATA_KEY).
  • The node strips that key from every model-produced message and stream event, so a model response cannot forge it.
  • ReactAgent.deliver checks the marker instead of the text prefix, shared by call and stream paths. The legacy call still returns the original Exception: ... message, and throwOnModelError=true behavior is unchanged.

Describe how to verify it

./mvnw -pl :argi-agent-framework -am test (1390 tests pass). New cases: normal answer with the prefix (call and stream), forged marker (call and stream), throwOnModelError=true, and the legacy call message.

Special notes for reviews

New public constant AgentLlmNode.MODEL_FAILURE_METADATA_KEY. Failure messages now carry this metadata key; no other public API changes.

@yuluo-yx yuluo-yx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the framework failure marker, model-output sanitization and call/stream regression tests. The frontend dependency audit failure is independent of this fix.

@yuluo-yx
yuluo-yx merged commit f503a2e into agentic-ai-java:main Oct 23, 2026
6 of 7 checks passed
@Duansg
Duansg deleted the fix/agent-model-failure-flag branch October 23, 2026 01:34
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][OPT-14] AgentResult 不应以回答正文的 Exception 前缀判断模型失败

2 participants