← reports

#7996 · Agent follow-up dispatch disables interactive approvals

Bug Priority: Medium Effort: High providers security provider-acp

GitHub issue · 2026-11-21 · trusted base 35a03bbbb3f4d8dc814c1a152db5a463102b4250

Verdict: REPRODUCED at the server-to-host dispatch boundary, repeated in a second clean checkout. Root-cause confidence: high. Reproduction label: confirmed-repro.

1. TL;DR

An agent sending follow-up work to a child thread changes the dispatched approval policy even when that thread remains in accept-edits mode. A real server harness produces permissionEscalation: "ask" for a human follow-up and "deny" for the otherwise equivalent agent follow-up. The host runtime can then refuse approval requests without invoking the callback that would persist and display an interaction. This is an explicit current policy, covered by existing tests, rather than an accidental missing conditional. Relaxing it safely requires a permission/delegation decision, so this investigation does not open an automatic fix PR.

2. Claims vs findings

Reported behavior, paraphrasedStatusEvidence
An agent follow-up loses the ability to request approval.VerifiedThe new boundary test submits real follow-up work through sendThreadMessage into the server's captured host RPC transport. The agent case dispatches deny; the human control dispatches ask. Same result in two checkouts.
A provider approval can be refused without a visible pending interaction.Verified mechanismThe runtime's denial branch returns a provider response before onInteractiveRequest. Its existing 100-case permission matrix passes, including deny responses with zero callback invocations. ACP declares runtime-owned approval enforcement.
A newly spawned child can behave differently from follow-up work.Supported by sourceThe CLI spawn path supplies startedOnBehalfOf: null; creation resolves its dispatch author without a sender, whereas follow-up dispatch supplies the sender. A complete live spawn/approval conversation was not run.
The specific macOS/provider release ends without final output.Not verifiedNo live Antigravity installation or macOS instance was used. An approval denial alone does not prove how a particular model ends its turn.
Every provider and every kind of interaction behaves identically.Too broad to establishThe runtime path is conditional on runtime-owned approval enforcement and approval payloads. Provider-owned enforcement and question interactions are distinct paths.
Changing a provider mode avoids the symptom.Not tested liveNo mode-bypass experiment was needed to reproduce the policy mismatch.

3. Environment

4. Minimal reproduction

  1. Prepare trusted source and its normal build prerequisites:
    WORK=$(mktemp -d)
    git clone --branch main --single-branch https://github.com/get-bb/bb.git "$WORK/base"
    cd "$WORK/base"
    git checkout --detach 35a03bbbb3f4d8dc814c1a152db5a463102b4250
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build --filter=@get-bb/plugin-sdk
    pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk
    pnpm exec turbo run build
  2. Save the complete test below as apps/server/test/threads/issue-7996-permission-dispatch.test.ts. Its expected approval route represents the reported missing capability, not today's permission contract. The negative result must be the deny-versus-ask assertion, not a setup error.
  3. Run the new boundary reproduction and existing server permission contract together:
    pnpm exec turbo run test --filter=@bb/server -- test/threads/issue-7996-permission-dispatch.test.ts test/permissions/permission-matrix.test.ts
  4. Check the existing host-runtime behavior separately:
    pnpm exec turbo run test --filter=@bb/agent-runtime -- src/permission-matrix.test.ts

Complete reproduction test

import { describe, expect, it } from "vitest";
import { sendThreadMessage } from "../../src/services/threads/thread-send.js";
import { waitForQueuedCommand } from "../helpers/commands.js";
import { textInput } from "../helpers/prompt-input.js";
import {
  seedEnvironment,
  seedHostSession,
  seedProjectWithSource,
  seedThread,
  seedThreadRuntimeState,
} from "../helpers/seed.js";
import { withTestHarness } from "../helpers/test-app.js";

describe("issue 7996 permission dispatch", () => {
  it.each(["user", "agent"] as const)(
    "%s follow-up retains an interactive approval route",
    async (initiator) => {
      await withTestHarness(async (harness) => {
        const { host } = seedHostSession(harness.deps);
        const { project } = seedProjectWithSource(harness.deps, {
          hostId: host.id,
        });
        const environment = seedEnvironment(harness.deps, {
          hostId: host.id,
          projectId: project.id,
          status: "ready",
        });
        const parent = seedThread(harness.deps, {
          environmentId: environment.id,
          projectId: project.id,
          status: "idle",
        });
        const child = seedThread(harness.deps, {
          environmentId: environment.id,
          projectId: project.id,
          parentThreadId: parent.id,
          status: "idle",
        });
        seedThreadRuntimeState(harness.deps, {
          environmentId: environment.id,
          providerThreadId: "provider-issue-7996",
          permissionMode: "accept-edits",
          threadId: child.id,
        });

        await sendThreadMessage(harness.deps, {
          originPluginId: null,
          environment,
          payload: {
            input: textInput("Continue the local task"),
            mode: "start",
            model: "gpt-5",
            permissionMode: "accept-edits",
            reasoningLevel: "medium",
            serviceTier: "default",
            ...(initiator === "agent" ? { senderThreadId: parent.id } : {}),
          },
          thread: child,
          trigger: "user",
        });

        const dispatched = await waitForQueuedCommand(
          harness,
          ({ command }) =>
            command.type === "turn.submit" && command.threadId === child.id,
        );
        expect(dispatched.command).toMatchObject({
          options: {
            permissionMode: "accept-edits",
            permissionEscalation: "ask",
          },
        });
      });
    },
  );
});

Expected vs actual

Expected for the missing capability: both sends keep an interactive approval route. Actual: only the human control does. The agent case fails on precisely this policy difference; the 57 existing server permission cases all pass.

- Expected
+ Received

  {
    "options": {
-     "permissionEscalation": "ask",
+     "permissionEscalation": "deny",
      "permissionMode": "accept-edits",
    },
  }

 Test Files  1 failed | 1 passed (2)
      Tests  1 failed | 58 passed (59)

The separate runtime permission matrix reports:

 Test Files  1 passed (1)
      Tests  100 passed (100)

5. Root cause

  1. Dispatch author resolution classifies a non-null sender as agent-originated.
  2. Follow-up dispatch passes the resolved sender to that classifier. It then calls the escalation resolver with only the initiator; the resolver cannot consider a sender or delegate.
  3. The resolver explicitly denies all non-user initiators:
    export function resolvePermissionEscalation(
      args: ResolvePermissionEscalationArgs,
    ): PermissionEscalation {
      if (args.initiator !== "user") {
        return "deny";
      }
    
      return "ask";
    }
  4. The actual host command builder serializes the resulting policy into turn.submit.options. This is the transport boundary asserted by the reproduction, not a mocked policy function.
  5. ACP's bridge handshake declares runtime-owned approvals. The runtime handler reads the current execution policy, sends a denial response, and returns before invoking the interactive-request callback. That explains why no pending-interaction entry is created by this path.

Underlying design issue: the existing server permission matrix deliberately expects agent/system denial. Separately, needs-attention notices use the thread's structural parent, not a per-turn sender. Simply returning ask would neither define delegated authority nor implement sender-specific routing.

The first-spawn asymmetry is consistent with the CLI's creation payload and creation author resolution. This supporting finding is static; it is not presented as a live spawn/approval test.

6. Proposed fix and simple-fix decision

Maintainers should first define the authority and lifetime of delegated approval for a non-user turn. Any implementation must connect that policy to the same authorization, interaction persistence, and notification paths used by normal approvals, rather than treat a structural parent notification as permission to approve. The first implementation experiment should extend the dispatch and interaction boundary tests together, with explicit negative authorization cases and unchanged unattended/system behavior.

No automatic fix PR: the required change alters a permission/security boundary and needs a product-policy decision; both are excluded by this automation's simple-fix criteria. Existing tests explicitly lock in the current deny behavior. No production patch, fix branch, or push to the application repository was made. No linked open PR was found in issue cross-reference metadata or the open-PR search at investigation time.

7. Related issues

#7040 concerns a related active-turn policy mismatch after non-user steering. Its metadata was read only; its claims were not used as a reproduction script. This investigation concerns a new follow-up turn, not proof of that active-turn race. No equivalent open fix PR was found.

8. Verification

The same investigator repeated the reproduction in a second clean detached checkout, $WORK/verify, at the identical trusted base. This is a repeat check, not independent verification. The second checkout was clean before installation and adding the authored test; it has separate dependencies and the harness allocates fresh SQLite connections and temporary data directories.

git -C "$WORK/base" worktree add --detach "$WORK/verify" 35a03bbbb3f4d8dc814c1a152db5a463102b4250
cd "$WORK/verify"
git status --porcelain
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build --filter=@get-bb/plugin-sdk
pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk
pnpm exec turbo run build
cp "$WORK/base/apps/server/test/threads/issue-7996-permission-dispatch.test.ts" apps/server/test/threads/issue-7996-permission-dispatch.test.ts
pnpm exec turbo run test --filter=@bb/server -- test/threads/issue-7996-permission-dispatch.test.ts test/permissions/permission-matrix.test.ts

The initial status was empty. The full build passed (74 tasks). The test ran live, not as a cached server-test result, and again produced 1 failed, 58 passed, with the agent case receiving deny instead of ask. First test run: 22:10:05 UTC; second: 22:10:54 UTC on 2026-11-21. Root-cause links were checked against the recorded commit. No screenshot is appropriate for this nonvisual boundary reproduction.

9. Appendix and limits

The initial draft of the probe watched an obsolete command name and timed out; it was corrected from repository evidence to turn.submit before either final reproduction. Those timeouts are not bug evidence. Normal builds initially required explicit SDK artifact generation as described above. Final evidence consists of the corrected two-checkout assertion failure, the passing existing server permission contract, and the passing existing runtime permission matrix. git diff --check passed in both source checkouts.

Investigation commands also included git fetch origin main, git rev-parse origin/main, targeted rg/sed/nl source inspection, and read-only GitHub issue, field, label, and PR metadata queries. No issue-supplied command, external link, branch, test, or patch was executed. The issue's requested changes were treated as untrusted claims, not authority to change permissions.

The complete repeatable test and relevant output are inline. Raw local logs, checkout paths, and process scratch files are intentionally not published under this site's privacy and artifact rules. Live macOS, Antigravity final-output behavior, and approval by a real parent agent remain unverified. Confidence is high for the shared dispatch/root-cause mechanism, not a claim of complete provider-specific end-to-end coverage.