Repository navigation
fix(harness): expose and inherit ConflictPolicy on HarnessAgent.Builder - #3263
Conversation
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
06996f8 to
8a23dcb
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
oss-maintainer
left a comment
There was a problem hiding this comment.
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
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: LGTM — approved. CI on ubuntu is green; the windows build was still in progress at review time. Automated review by github-manager-bot |
|
@jujn 这个 PR 审核已经通过了,CI 也全绿了。麻烦您了。 |
…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
AgentScope-Java Version
2.0.4-SNAPSHOT, branched frommain@ed77530a4. Reproduces on currentmain.Description
Fixes #3260.
HarnessAgent.Builderforwards every other state-persistence knob onto the innerReActAgent.Builder(stateStore(...),defaultSessionId(...)) but notconflictPolicy(...), so a harness user cannot opt out of last-writer-wins onagent_state— while both
docs/v2/en/docs/others/going-to-production.mdand the distributed integrationpage recommend
ConflictPolicy.FAILfor multi-replica deployments. The losing write isdropped 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 copiesagent.getStateStore()but notagent.getConflictPolicy(), so an agent deliberatelyconfigured with
FAILis silently downgraded toOVERWRITEonce wrapped in a harness agent.That reads as a bug rather than a missing feature.
Changes (+71/−1,
agentscope-harnessonly): aconflictPolicy(...)setter written the sameway as the sibling setters in that class; a
getConflictPolicy()passthrough getter next tothe existing
getStateStore();fromAgent()inheriting the policy, with the inheritancetable in its javadoc updated; and 3 tests in
HarnessAgentTestcovering the default,FAILreaching the delegate, and
fromAgentinheritance. Leaving the setter unset keeps today'sOVERWRITE, so no behaviour change for existing code, and the new public surface is onesetter and one getter.
mvn -pl agentscope-harness spotless:checkclean;HarnessAgentTest54/54;HarnessAgent*Test96/96.One thing to decide:
fromAgentcurrently inherits unconditionally, following #3260'sreasoning that
getConflictPolicy()reports the source agent's effective policy. If youwould rather it copy only when the policy is non-default, that is a one-line change.