fix: preserve parent RuntimeContext in harness subagent delegation#1756
fix: preserve parent RuntimeContext in harness subagent delegation#1756guslegend0510 wants to merge 8 commits into
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
This PR adds RuntimeContext.fork() to preserve parent context (string extras, typed attributes, and ToolExecutionContext) when delegating to harness subagents, and threads the parent RuntimeContext through DefaultAgentManager and AgentSpawnTool invocation paths. The design is clean: fork() creates isolated snapshot copies of attribute maps (copy-on-fork semantics), preventing parent-child interference, while sharing the ToolExecutionContext by reference (appropriate for a DI container). The old overloads delegate to new ones with null parentContext, maintaining backwards compatibility. Test coverage is solid, verifying both sync and stream paths with typed attributes, string extras, ToolExecutionContext identity, and agentState isolation. One pre-existing gap worth noting: the plain Agent fallback in invokeAgent/invokeAgentStream still calls agent.call(prompt) without the computed ctx — not introduced by this PR, but now more visible.
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
This PR adds RuntimeContext.fork() to preserve parent context (string extras, typed attributes, and ToolExecutionContext) when delegating to harness subagents, and threads the parent RuntimeContext through DefaultAgentManager and AgentSpawnTool invocation paths. The design is clean: fork() creates isolated snapshot copies of attribute maps (copy-on-fork semantics), preventing parent-child interference, while sharing the ToolExecutionContext by reference (appropriate for a DI container). The old overloads delegate to new ones with null parentContext, maintaining backwards compatibility. Test coverage is solid, verifying both sync and stream paths with typed attributes, string extras, ToolExecutionContext identity, and agentState isolation. One pre-existing gap worth noting: the plain Agent fallback in invokeAgent/invokeAgentStream still calls agent.call(prompt) without the computed ctx — not introduced by this PR, but now more visible.
|
We're building an enterprise agent-governance platform on AgentScope-Java RC3, and this PR fixes a blocker for us: harness subagent delegation drops the parent We reviewed the patch against RC3 and it looks complete on the delegation surface: Two notes that might help it land:
Looking forward to seeing this in a release. |
|
@chickenlj 回复你了,麻烦看一下,谢谢您 |
Summary
Validation