Repository navigation
feat(harness): persist team membership for existing sessions - #3425
dailingtao wants to merge 14 commits into
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
A JdbcStore ObjectMapper configured with NON_NULL legitimately omits null owner fields, but the strict decoder rejected such committed relationship records, making them unreadable. Nullable fields now decode as null when absent while required fields and schema checks still reject damaged data.
All associations are application-supplied BYO and no behavior branches on the enum, so remove it and its persisted field before first release. Previously written records remain readable; the unknown field is ignored.
guslegend0510
left a comment
There was a problem hiding this comment.
Thanks for the work! I ran the related tests locally and they pass. Two problems before LGTM:
1. A failed adoption can break a Team for good
If I adopt Team B with a Session that is already in Team A, adoption fails. But Team B still gets marked as "PENDING", and after that:
listMembersandbroadcastMessageon Team B throw errors- I can't retry with a different Session either ("different adoption request")
So one wrong call breaks Team B until Team A lets go of that Session.
Please check for this conflict before writing the marker. Also, while a Team is PENDING, listMembers could just return the old list instead of throwing.
2. Duplicate-key check in JdbcStore misses some databases
The new check only knows PostgreSQL/H2, MySQL 1062 and SQLite. Oracle, SQL Server and MySQL 1022 duplicates now throw an exception instead of returning false. That can break existing code like RemoteFilesystem.write for people who use those databases through a custom dialect.
JdbcAgentSkillRepository.isUniqueViolation in the same module already handles all of these. Could you reuse it?
Keep the legacy member directory and broadcasts available while adoption is pending. Share precise JDBC duplicate-key classification with Skill to preserve existing-file failures across supported diagnostics.
|
@guslegend0510 Thanks for reproducing these and calling them out. Both are addressed in a24076e0.
Validation: 118 targeted tests passed with no failures/errors/skips; all 96 reactor modules passed |
|
@chickenlj jun哥 这个PR 有时间也可以看下, 是对齐 py 那边 agent team 相关的 PR |
AgentScope-Java Version
2.1.0-SNAPSHOT; current head
899482ad4, including main through035487ea1.Description
Harness already stores Team metadata and declared Agent members, with task boards and mailboxes. Applications still lack persistent membership for specific Sessions: the existing
bindSessiononly registers notifications in memory. They cannot recover those associations after restart or enforce unique Session membership across clients.This PR adds an explicitly enabled Java API to register, query and safely remove Team membership for existing Sessions:
This implements the Session-membership part of #1998 for existing Leader and BYO (application-supplied) Sessions.
Usage
Use the existing
createTeamto declare the Team and members; their Sessions must already be persisted. Given that Team'saddress,leaderandworker(MemberSessionvalues), and theirstateStore:adoptTeamrequires exactly one initial Leader and optional BYO members.getTeamandlistMembershipsquery the Team and current associations. Binding is restricted to its declared members.Reactive callers compose the returned
Monooperations; this fragment uses.block()at an application entry point. See the full setup and contracts (also documented in Chinese).Storage and consistency
namespace/teamNameaddress; the new relationship record stores only associations and adoption receipts.BaseStore.supportsAtomicSessionStorage()andputIfVersion, the same capability used by nativeStoreSessionStorage. In-memory and JDBC stores already declare support; JDBC provides restart persistence. The default capability remainsfalsefor legacy/custom providers. Record size/contention grows with the owner's associations.PENDING; retrying the same complete request can resume it. Committed replays do not restore members removed later.CAS contention has bounded retries; storage errors propagate. The common JDBC, independent MySQL and PostgreSQL providers recognize specific duplicate-key signals and preserve other SQL failure causes. Private schema-1 records accept historical BYO data and reject unknown formats without resetting data; long storage addresses use bounded encodings.
Compatibility and scope
Existing
TeamClientimplementations, public records/JSON and staticteamsModeremain available. No additional storage SPI is introduced: custom stores opt into the existingBaseStorecapability and honor its atomicity/error contract. Adopted Teams'listMembersprojects Session IDs from the same relationships; unbound declarations have an empty ID.PENDINGpreserves the original directory.completeTeampreserves membership; enabled clients and clients observing adopted Teams use strict CAS.Before adoption, stop/drain older or unenabled writers, upgrade all writers, and enable each client. Adopted Teams do not support mixed-version writes. Rollback requires a compatible reader or restoring a pre-adoption backup with writers stopped.
This trusted programming API uses explicit
AgentStateStoremappings andSessionKey(stateStoreDomain, owner, sessionId). Session and Team owners must match. Applications provide consistent store-domain IDs and definition authorization. Native 2.1AgentSession/SessionLogdiscovery and identity mapping are not automatic.The unmerged draft
VersionedBaseStorehas been removed. Clients using that draft type must switch toBaseStore, explicitly declare the capability and recompile; persisted membership data needs no migration.This change does not add model tools, Worker creation, scheduling or Service Team/Run integration. Unbinding does not stop runs, revoke permissions or unregister notifications.
Closes #3424
Related to #1998; the broader App Teams request remains open.
Related to #3422; its notification-isolation patch is separate and is not included here.
Validation
Implementation validation at
863cccafd(Java 17, macOS). Current head899482ad4only restores existing comment wording; comparison with comments removed confirms identical Java source. Spotless and diff checks passed for that follow-up; the full suite was not rerun for comment-only edits:mvn -B -T1 clean verify: all 97 reactor modules passed, with 10,809 reported tests, zero failures/errors and 225 conditional or previously disabled skips (10,584 executed and passed).BaseStoredeclaring the existing capability, legacy providers retaining defaultfalse, and reuse by nativeStoreSessionStorage. These checks exposed the old interface restriction before the change. SQL regressions likewise failed before correcting the constraint classification.mvn -B -T1 -pl agentscope-extensions/agentscope-extensions-jdbc,agentscope-extensions/agentscope-extensions-mysql,agentscope-extensions/agentscope-extensions-postgresql -am spotless:apply test -Dtest=TeamSessionMembershipTest,LocalTeamClientTest,TeamSessionMembershipH2Test,JdbcStoreH2Test,JdbcStoreConstraintTest,JdbcAgentSkillRepositoryH2Test,JdbcAgentSkillRepositorySqliteTest,PostgresBaseStoreTest.npm test(13 passed),npm run validate, andnpm run broken-linkspassed. Final Spotless and diff checks passed.DashScopeNonStreamingBlockingBehaviorTest.testDashScopeChatModelNonBlockingat line 86 (expected: not <null>); Harness and the changed storage modules were skipped after that failure.Checklist
mvn spotless:apply