Cross-agent delegateToolsTo worker loses exec after coordinator completion continuation

Summary

A restricted coordinator can launch an explicitly authorized worker with exec, but launching another worker from a verified completion continuation records the coordinator’s local execution denials in the new worker’s delegated deny floor. The second worker cannot execute.

Please confirm whether this is an intended limitation or a defect, and whether there is an officially supported continuation pattern or existing fix. We do not want to remove inherited/sender restrictions or enable execution on the coordinator.

Environment

  • Official source commit: 6f88c26dcf823a6d5c99a6053316829edc1a6512
  • macOS arm64, Node 24.22.1
  • Source-built installation, Gateway on the same machine
  • Gateway-native local subagents; OpenAI-compatible fallback execution
  • Explicit allowAgents and delegateToolsTo grants remain configured.

Observed behavior

  1. Ordinary coordinator request launches worker. Worker’s persisted delegatedToolPolicy.deny excludes coordinator-local exec/process/edit denies. Real execution succeeds.
  2. Coordinator calls sessions_yield and receives completion.
  3. Coordinator launches a new authorized worker. Its persisted delegatedToolPolicy.deny now includes the coordinator-local denies.
  4. New worker cannot discover exec; subsequent attempts report execution outside the completion requester’s authority. Switching worker or language does not resolve it.

Offline reproduction

This uses existing fixtures in src/agents/delegated-tool-policy.test.ts at the commit above. Append this diagnostic in that file (no live account, model, channel, or production state required):

it("compares ordinary and completion successor delegation floors", () => {
  const cfg = config();
  const ordinary = prepareFloor(profile(cfg));
  const wake = profile(cfg, {
    sessionId: "parent-id",
    modelProvider: "test",
    modelId: "model",
    preparedSessionCapabilityStore: { [child]: entry() },
    inputProvenance: {
      kind: "inter_session",
      sourceSessionKey: child,
      sourceTool: "subagent_announce",
    },
    trustedInternalHandoff: {
      kind: "subagent-completion",
      sourceSessionKey: child,
      targetSessionKey: requester,
      targetSessionId: "parent-id",
      provider: "test",
      model: "model",
    },
  });
  expect(wake.policy.requesterPolicySource).toBe("completion-handoff");
  const resumed = prepareFloor(wake);
  expect(ordinary?.deny).not.toContain("exec");
  expect(resumed?.deny).toContain("exec");
});

The 23 existing assertions and this diagnostic passed in isolation. Diagnostic output:

{
  "ordinary": {"policyAgentId":"front","deny":[]},
  "resumed": {"policyAgentId":"front","deny":["exec","write","edit","apply_patch"]}
}

This demonstrates the difference, not a successful repair. The live workflow used an actual yield; the synthetic diagnostic above uses the existing trusted-completion fixture and does not independently exercise the full settle-batch lifecycle.

Suspected path, not a maintainer-confirmed root cause

requester-tool-policy.ts restores requesterDeny on completion. prepareDelegatedToolDenyFloor subsequently includes inheritedToolPolicyForSpawn, so replayed coordinator-local restrictions become nonlocal restrictions for the next handoff.

Expected constraints

  • Coordinator remains unable to execute.
  • Current explicit target grant can support subsequent authorized handoffs.
  • Genuine global/provider/sender/sandbox/ancestor restrictions remain enforced.
  • Existing child envelopes must not be cleared or silently widened.
  • Grant revocation remains effective.

Related documentation and changes

No credentials, account identifiers, group identifiers, business documents, or production transcripts are included.

Hey there Simon, welcome to the community!

Thank you for the exceptionally detailed report. You’ve done a tremendous amount of the diagnostic work already.

I’ve reviewed the delegation contract and the relevant code paths. What you’re describing appears consistent with a policy-propagation defect, particularly where the coordinator’s captured execution restrictions are restored during completion and subsequently included in the deny floor for another authorized worker.

Preserving those restrictions on the coordinator is intentional. Whether they should prevent a new, explicitly authorized delegation is the important distinction here.

One detail worth flagging: your synthetic reproduction uses subagent_announce, while the actual sessions_yield settlement uses subagent_settle. That doesn’t invalidate your findings, but it means we’ll want the maintainers to verify the full continuation path before confirming the root cause.

I wouldn’t recommend weakening your security configuration or applying the closed #168613 changes.

Could you open a GitHub issue with this reproduction and link it here? This deserves engineering triage rather than another round of configuration troubleshooting.

I appreciate how carefully you’ve documented this, particularly your attention to maintaining the existing security boundaries.

-Joe