Repository navigation
Description
Problem
AgentSpawnTool currently propagates only parent DENY rules through propagateDenyRules(...). Parent working directories, ALLOW rules and ASK rules are not inherited into the child (userId, sessionId) permission context. The update also targets the deprecated/default PermissionEngine view rather than an atomic persisted slot update, so it is not recoverable after restart.
For timeout_seconds=0, a local child that returns GenerateReason.PERMISSION_ASKING is treated as a normally completed LocalTaskRunSpec with an empty result. TaskStatus has no non-terminal approval state, so the task cannot be durably resumed after approve/deny, cancellation or process restart.
These two gaps force product hosts to wrap AgentSpawnTool and couple to its private SpawnedAgent, registry maps, persistence method and execution method in order to preserve full permission inheritance and HITL continuation. Exposing those private fields is not the desired fix; the native spawn workflow should remain the owner.
Observed against agentscope-java commit e3a412ed2cc944e401da861c8d5e464b967724e9.
Proposed contract
Atomic child permission inheritance
Provide a Core/Harness API used by AgentSpawnTool that atomically:
- loads the actual child slot identified by
(userId, sessionId); - merges parent working directories plus ALLOW/DENY/ASK according to
inheritParentPermissions; - updates both
AgentState.permissionContextand the matchingPermissionEnginecache; - persists the state before child execution;
- preserves child-specific rules and mode with deterministic merge precedence.
Typed async HITL suspension
Allow an async subagent task to remain non-terminal when the child returns PERMISSION_ASKING, for example TaskStatus.WAITING_FOR_APPROVAL or an equivalent typed state. Persist enough continuation identity to support:
- approve -> resume the same child session and complete the same task;
- deny -> resume and complete with the denial result;
- cancel while waiting;
- restart / another replica -> recover and resume;
- no polling of child state by the product host.
The task repository/scheduler should own wakeup and terminal transition. AgentSpawnTool, agent_send, task output/list/cancel and child event forwarding should continue to use the same native registry and persisted spawn workflow.
Acceptance cases
- Parent ALLOW, DENY and ASK rules plus working directories are visible in the child slot before the first tool call.
- ASK pauses a sync and async spawned child; approve and deny both continue the original turn.
- An async task is not reported
COMPLETED("")while approval is pending. - Approval continuation survives state-store recreation and process/replica restart.
- Cancellation while waiting does not leave an orphan child.
- Persisted children still support
agent_send, labels, exposure/lineage and workspace isolation. - No product-host access to private
AgentSpawnToolregistries orReActAgent.permissionEngineCacheis required.
Why this belongs in Harness/Core
Permission state, spawned-child registry, task lifecycle, scheduler wakeup and recovery are one runtime transaction. Implementing only a public getter for the private spawn maps would move ownership into every host and make distributed recovery inconsistent. The public seam should be behavioral and native, not reflective state access.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn progress
Activity
richuV commentedon Jul 12, 2026
Additional real-provider evidence (AgentScope Java 2.0.x consumer, qwen3.6-flash):
agent_spawn(timeout_seconds=0): one shell child and one read-before-edit child.edit_filepermission ASK. Before approval the file was unchanged.ToolUseBlockproducedToolResultEnd(SUCCESS)for that exact tool call and the Harness filesystem readback observed the edit.TaskRecords remainedRUNNINGfor more than three minutes and both exposedsubSessionId=null. Neither task reached a confirmed terminal result/delivery state.PERMISSION_ASKINGcan collapse toCOMPLETED("")when the host bridge is absent.This supports acceptance cases 2-4 and also shows that durable task-to-child-session lineage is required for wakeup/readback. On the consumer side we now fail an unconfirmed async continuation instead of reporting empty success, but we cannot complete or wake the
TaskRecordwithout taking over Harness task ownership. No private task completion store was added.oss-maintainer commentedon Jul 14, 2026
xuchaoguo1983 commentedon Sep 25, 2026
Adding a security angle to this issue: on 2.0.3 the gap is not only a missing feature. Because ASK rules and the DEFAULT-mode "undeclared tool → ASK" behaviour are not inherited, the default
general-purposesubagent executes tools that require human confirmation on the parent, without any confirmation.Why it happens (2.0.3)
HarnessAgentBuilderSupport.buildGeneralPurposeFactorybuilds the child with a copy of the parent toolkit (capturedParentToolkit.copy()), but without a permission context.PermissionContextStateis therefore trivial (isTrivial() == true), soReActAgent.evaluateOneskips thePermissionEngineand uses the tool's owncheckPermissions. For a normalToolBasethat returnspassthrough, and passthrough is treated as ALLOW.AgentSpawnTool.propagateParentDenyRulesonly copies DENY rules, and does nothing when the parent has none.Minimal reproduction (verified with a scripted model, AG-UI, Redis state store)
PermissionMode.DEFAULT, a business toolTwith an ASK rule (or no rule at all), and the built-inagent_spawnavailable.Tdirectly on the parent pauses for confirmation, as expected.agent_spawn(agent_id="general-purpose")so that the child callsTrunsTimmediately. The parent turn emits no interrupt, and the tool's side effect happens.Impact
HITL confirmation is the main guard against prompt injection for destructive tools. With the default harness setup, any input that makes the model delegate to a subagent bypasses it.
Because of this, it may be worth treating the permission-inheritance part of #2177 as a bug fix rather than an enhancement, even if it is split from the async-HITL suspension work. Until then, a child that inherits the parent's rules and fails closed on ASK (not executed) would already remove the bypass.