feat(agent): logical agentId - #2395
Open
rudy2steiner wants to merge 5 commits into
Open
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
看描述和实现 |
Contributor
Author
yes |
|
AgentSkillRepository有考虑增加一个agentId回调? |
Contributor
Author
|
@chickenlj could you review this PR when you have time ? Thanks a lot! |
oss-maintainer
approved these changes
Jul 28, 2026
oss-maintainer
left a comment
Collaborator
There was a problem hiding this comment.
Summary
Introduces a logical agentId concept separate from the runtime UUID id. Clean separation of concerns across 22 files.
Analysis
Design is sound:
id= runtime UUID (unique per Java object instance)agentId= stable logical identity (user-provided, for routing/telemetry/state)name= display name (human-readable, for messages/logs)
Backward compatibility preserved:
getAgentId()defaults togetId()when no explicit agentId is set- Existing code that uses
getName()for resource paths is migrated togetAgentId()— this is the correct semantic change sincenamewas being overloaded
Key changes reviewed:
Agentinterface: defaultgetAgentId()with fallback — clean SPI extensionAgentBase: storesagentIdfield, constructor updatedReActAgent.Builder/HarnessAgent.Builder:agentId(String)builder method +fromAgent()propagation- Middleware (MemoryFlush, Compaction): correctly switched from
getName()togetAgentId()for state paths EventPublisher: usesgetAgentId()for event routing — correctHarnessAgent.defaultStateDir(): usesgetAgentId()— ensures state isolation by logical identity- Tests: comprehensive coverage of explicit agentId, name fallback, and UUID fallback
One consideration:
- The migration from
getName()togetAgentId()for state paths means existing deployments that relied onnamefor state directory naming will see a different directory on upgrade (unless they setagentIdto match the oldname). This should be noted in release notes.
Verdict
Well-structured feature. Addresses a real architectural concern (identity conflation). Build and tests pass. Approved.
This reverts commit 9c6418c.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
agentIdcurrently serves several different purposes in AgentScope Java:These meanings conflict when the same logical Agent is recreated or scaled to multiple runtime instances. The current random UUID changes for every instance, so platforms must maintain an additional mapping between their stable Agent ID and AgentScope's generated ID which discussed in #2313. However, simply making the existing ID configurable would allow multiple instances to share a value that internal state maps currently assume is unique, potentially causing state, trace, or training data to be overwritten or mixed.
This change separates the two identity concepts:
agentIdis the stable, caller-defined logical Agent ID.idis the random UUID of a specific runtime Agent instance.This allows platform integrations to use a stable logical identity while preserving the existing
instance-level isolation.
Main Changes
Agent#getId()for runtime instance identity.AgentBasealways generates an immutableUUID for it, while the default interface implementation falls back to
getAgentId()forcompatibility with existing custom
Agentimplementations.agentId. If it is null or blank, it fallsback to the generated runtime
id, preserving the previous default behavior.ReActAgent.Builder.agentId(String).ReActAgent, soHarnessAgent#getAgentId()now matches the logical ID already used by Harness resourcenamespaces. The existing Harness resolution order and resource paths remain unchanged.
id, including graceful-shutdown state savers,JSONL trace run state, and TrainingRouter input correlation. This prevents collisions when
multiple runtime instances share one logical
agentId.SubAgentTool.subagent_idcontinues to identify a unique runtime sub-agent instance by usingid.default UUID behavior, Harness propagation, and isolation between instances sharing the same
logical ID.