agentscope-ai / agentscope-ai/agentscope-java

[Feature]: subagent-inherit-parent-context

Ouverte
#1,912 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
area/core/agent enhancement
Langage dominant
Java
Étoiles
5.6k
Forks
1.3k
Merge moyen
4 j 12 h
PR mergées (30 j)
77

Description

fix(harness): inherit parent business context into spawned subagents

Problem: When a subagent is spawned, DefaultAgentManager.invokeAgent / invokeAgentStream build a fresh RuntimeContext carrying only (sessionId, userId). The parent's custom typed/string attributes —
request-scoped business POJOs injected via RuntimeContext.put(Class, …) — are dropped. Tools relying on framework auto-injection of those POJOs (non-@ToolParam params resolved by ToolMethodInvoker →
RuntimeContext.get(Class)) therefore receive null inside a spawned subagent, though they work on the main agent. Only userId is propagated today.

Fix: invokeAgent/invokeAgentStream gain an overload taking an optional parentRc; the child RC is built via RuntimeContext.builder().from(parentRc) then overlaid with the child's own sessionId/userId.
AgentState is rebound per-call in beforeAgentExecution, so carrying the parent's reference is harmless. AgentSpawnTool forwards the parent RC on both sync (execLocalSync) and async (task) paths. Old
signatures preserved (parentRc = null) → backward compatible.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.