Skip to content

Harness: native full subagent permission inheritance and typed async HITL suspension #2137

Open

Description

@richuV

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.permissionContext and the matching PermissionEngine cache;
  • 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

  1. Parent ALLOW, DENY and ASK rules plus working directories are visible in the child slot before the first tool call.
  2. ASK pauses a sync and async spawned child; approve and deny both continue the original turn.
  3. An async task is not reported COMPLETED("") while approval is pending.
  4. Approval continuation survives state-store recreation and process/replica restart.
  5. Cancellation while waiting does not leave an orphan child.
  6. Persisted children still support agent_send, labels, exposure/lineage and workspace isolation.
  7. No product-host access to private AgentSpawnTool registries or ReActAgent.permissionEngineCache is 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.

Activity

  1. added
    enhancement
    area/harness
    on Jul 12, 2026
  2. richuV commented on Jul 12, 2026

    @richuV
    Author

    Additional real-provider evidence (AgentScope Java 2.0.x consumer, qwen3.6-flash):

    • A parent turn successfully created two local async children through agent_spawn(timeout_seconds=0): one shell child and one read-before-edit child.
    • The edit child reached a typed edit_file permission ASK. Before approval the file was unchanged.
    • Approving the original ToolUseBlock produced ToolResultEnd(SUCCESS) for that exact tool call and the Harness filesystem readback observed the edit.
    • Despite that successful continuation, both Harness TaskRecords remained RUNNING for more than three minutes and both exposed subSessionId=null. Neither task reached a confirmed terminal result/delivery state.
    • The behavior reproduced in the full graded daily run; deterministic canaries also confirm native PERMISSION_ASKING can collapse to COMPLETED("") 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 TaskRecord without taking over Harness task ownership. No private task completion store was added.

  3. moved this from Backlog to In progress in AgentScope Javaon Jul 13, 2026
  4. oss-maintainer commented on Jul 14, 2026

    @oss-maintainer
  5. xuchaoguo1983 commented on Sep 25, 2026

    @xuchaoguo1983

    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-purpose subagent executes tools that require human confirmation on the parent, without any confirmation.

    Why it happens (2.0.3)

    • HarnessAgentBuilderSupport.buildGeneralPurposeFactory builds the child with a copy of the parent toolkit (capturedParentToolkit.copy()), but without a permission context.
    • The child's PermissionContextState is therefore trivial (isTrivial() == true), so ReActAgent.evaluateOne skips the PermissionEngine and uses the tool's own checkPermissions. For a normal ToolBase that returns passthrough, and passthrough is treated as ALLOW.
    • AgentSpawnTool.propagateParentDenyRules only copies DENY rules, and does nothing when the parent has none.

    Minimal reproduction (verified with a scripted model, AG-UI, Redis state store)

    • Parent: PermissionMode.DEFAULT, a business tool T with an ASK rule (or no rule at all), and the built-in agent_spawn available.
    • Calling T directly on the parent pauses for confirmation, as expected.
    • Calling agent_spawn(agent_id="general-purpose") so that the child calls T runs T immediately. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/harnessenhancement

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions