Skip to content

fix(harness): expose and inherit ConflictPolicy on HarnessAgent.Builder - #3263

Merged
jujn merged 1 commit into
agentscope-ai:mainfrom
Cshvee:fix/harness-conflict-policy
Oct 6, 2026
Merged

jujn merged 1 commit into
agentscope-ai:mainfrom
Cshvee:fix/harness-conflict-policy

Conversation

@Cshvee

@Cshvee Cshvee commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.0.4-SNAPSHOT, branched from main @ ed77530a4. Reproduces on current main.

Description

Fixes #3260.

HarnessAgent.Builder forwards every other state-persistence knob onto the inner
ReActAgent.Builder (stateStore(...), defaultSessionId(...)) but not
conflictPolicy(...), so a harness user cannot opt out of last-writer-wins on agent_state
— while both docs/v2/en/docs/others/going-to-production.md and the distributed integration
page recommend ConflictPolicy.FAIL for multi-replica deployments. The losing write is
dropped without an error; the visible symptom is a stale or garbled session much later.

Builder.fromAgent(ReActAgent) is the worse shape of the same gap: it copies
agent.getStateStore() but not agent.getConflictPolicy(), so an agent deliberately
configured with FAIL is silently downgraded to OVERWRITE once wrapped in a harness agent.
That reads as a bug rather than a missing feature.

Changes (+71/−1, agentscope-harness only): a conflictPolicy(...) setter written the same
way as the sibling setters in that class; a getConflictPolicy() passthrough getter next to
the existing getStateStore(); fromAgent() inheriting the policy, with the inheritance
table in its javadoc updated; and 3 tests in HarnessAgentTest covering the default, FAIL
reaching the delegate, and fromAgent inheritance. Leaving the setter unset keeps today's
OVERWRITE, so no behaviour change for existing code, and the new public surface is one
setter and one getter.

mvn -pl agentscope-harness spotless:check clean; HarnessAgentTest 54/54;
HarnessAgent*Test 96/96.

One thing to decide: fromAgent currently inherits unconditionally, following #3260's
reasoning that getConflictPolicy() reports the source agent's effective policy. If you
would rather it copy only when the policy is non-default, that is a one-line change.

@CLAassistant

CLAassistant commented Sep 23, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

The builder mirrored every other persistence knob onto the inner
ReActAgent.Builder but not the conflict policy, so a harness agent could
never opt out of last-writer-wins on agent_state — even though
ConflictPolicy.FAIL exists for exactly the distributed turn-gate setup the
enum javadoc recommends, and even though losing writers are discarded
silently and only show up later as a stale session.

fromAgent() had the same gap in a worse form: it copied the state store
but not agent.getConflictPolicy(), so wrapping an agent that was
deliberately configured with FAIL quietly downgraded it to OVERWRITE.
Since getConflictPolicy() reports the source agent's effective policy,
fromAgent now copies it unconditionally rather than special-casing the
enum default.

Fixes agentscope-ai#3260
@Cshvee
Cshvee force-pushed the fix/harness-conflict-policy branch from 06996f8 to 8a23dcb Compare September 23, 2026 10:19
@codecov

codecov Bot commented Sep 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@oss-maintainer oss-maintainer 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.

Summary

Clean, well-tested change: now exposes , the builder gains a passthrough, and inherits the source agent's policy (defaulting to via the existing null-safe coercion in ). The three new tests cover default, explicit-forwarding, and inheritance — nice.

LGTM. CI on ubuntu is green; windows build was still in progress at review time.


Automated review by github-manager-bot

@oss-maintainer

Copy link
Copy Markdown
Collaborator

Review summary (formatted re-post)

Reposting the approval summary with intact formatting (the inline-code spans were stripped from review #5289852748's body):

Clean, well-tested change: HarnessAgent now exposes getConflictPolicy(), the builder gains a conflictPolicy(...) passthrough, and fromAgent inherits the source agent's policy (defaulting to OVERWRITE via the existing null-safe coercion in ReActAgent). The three new tests cover the default, explicit forwarding to the delegate, and fromAgent inheritance.

LGTM — approved. CI on ubuntu is green; the windows build was still in progress at review time.


Automated review by github-manager-bot

@Cshvee

Cshvee commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

@jujn 这个 PR 审核已经通过了,CI 也全绿了。麻烦您了。

@jujn
jujn merged commit e05d45e into agentscope-ai:main Oct 6, 2026
6 checks passed
chickenlj pushed a commit that referenced this pull request Nov 13, 2026
…er (#3263)

Backport the verified fix to the 2.0.x implementation and retain its existing public contracts where the upstream kernel differs.

(cherry picked from commit e05d45e)
Backport-review-patch: d8573c061722e074143b7e66a26fa926c39ecf1a
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.

[Bug]: HarnessAgent cannot configure ConflictPolicy, and Builder.fromAgent() silently drops the source agent's policy

4 participants