Skip to content

[Bug]: ACP approvals trim opaque option IDs and turn whitespace-only IDs into cancellation #35822

Closed as not planned

Description

@coygeek

Summary

Approving a tool request can return a different permission option ID from the one the ACP agent offered. If the ID contains only whitespace, the same approval instead becomes a cancellation. A focused run through the shared provider adapter reproduced both cases while ordinary approval, interruption, and Kiro permission controls passed. Selecting a permission option should preserve its exact ID.

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Use a checkout at 59e64eef881632a23f89c4138bcf37f23d92bf93 with its lockfile dependencies installed.
  2. Save and run the script below against that checkout. It adds two input rows to the existing adapter permission test in a disposable detached worktree; production source stays unchanged.
  3. Observe both identity assertions fail, while six control cases pass: the existing two ordinary approval cases, pending-permission cancellation during interruption, the stale Kiro session-approval response, and two Kiro permission-policy cases.

Both failing cases were deterministic in the completed focused run. A preliminary run reached the same two assertion failures and six passing controls but its result parser mistakenly counted skipped tests as controls and printed RESULT: inconclusive; the exact final script below corrected only that parser and added the actual response to assertion diagnostics, then exited 1 with RESULT: defect reproduced.

Save this as repro-permission-option-id.sh and run sh repro-permission-option-id.sh /path/to/t3code. Prerequisites are POSIX sh, Git, Python 3, the repository's pinned Node runtime, and installed lockfile dependencies including Vite+. It creates its worktree, fixtures, HOME, temporary directory, and T3 state under mktemp -d, uses only fake agents, runs one worker, and removes its worktree and scratch on exit. Exit 0 means both IDs were preserved, exit 1 means both identity assertions reproduced the defect with all controls passing, and exit 2 means setup, a control, or the result classification was inconclusive.

Reproduction script: repro-permission-option-id.sh
#!/bin/sh
set -u
checkout=${1:?Usage: sh repro-permission-option-id.sh /path/to/t3code}
checkout=$(cd "$checkout" && pwd -P) || exit 2
scratch=$(mktemp -d /tmp/acp-option-id.XXXXXX) || exit 2
wt=$scratch/wt
cleanup() {
  git -C "$checkout" worktree remove --force "$wt" >/dev/null 2>&1 || :
  rm -rf "$scratch"
}
trap cleanup EXIT HUP INT TERM
finish() {
  case "$1" in
    0) echo 'RESULT: expected behavior' ;;
    1) echo 'RESULT: defect reproduced' ;;
    *) echo 'RESULT: inconclusive' ;;
  esac
  exit "$1"
}
mkdir -p "$scratch/home" "$scratch/tmp" "$scratch/state" || finish 2
export HOME=$scratch/home TMPDIR=$scratch/tmp T3CODE_HOME=$scratch/state
unset T3_BOOT_SERVICE_UNIT T3_SERVICE_LAUNCHER_CONTEXT
git --version || finish 2
node --version || finish 2
python3 --version || finish 2
"$checkout/node_modules/.bin/vp" --version || finish 2
git -C "$checkout" rev-parse HEAD || finish 2
git -C "$checkout" worktree add --detach "$wt" HEAD >"$scratch/setup.log" 2>&1 || finish 2
python3 - "$checkout" "$wt" <<'PY' || finish 2
import os, pathlib, sys
source, worktree = map(pathlib.Path, sys.argv[1:])
for folder, dirs, _ in os.walk(source):
    dirs[:] = [d for d in dirs if d not in {'.git', '.t3', '.repos'}]
    if 'node_modules' in dirs:
        original = pathlib.Path(folder) / 'node_modules'
        target = worktree / original.relative_to(source)
        target.symlink_to(original, target_is_directory=True)
        dirs.remove('node_modules')
test = worktree / 'apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts'
text = test.read_text()
anchor = '      label: "answers Always allow with the agent\'s allow-always option",'
position = text.index('    {\n' + anchor)
rows = '''    {
      label: "group05 preserves a permission option ID containing surrounding spaces",
      options: [
        { optionId: " opaque-choice ", name: "Allow once", kind: "allow_once" },
        { optionId: "deny", name: "Reject", kind: "reject_once" },
      ],
      optionId: " opaque-choice ",
    },
    {
      label: "group05 preserves a permission option ID containing only whitespace",
      options: [
        { optionId: " ", name: "Allow once", kind: "allow_once" },
        { optionId: "deny", name: "Reject", kind: "reject_once" },
      ],
      optionId: " ",
    },
'''
test.write_text(text[:position] + rows + text[position:])
text = test.read_text()
assertion = '      assert.deepEqual(outcome, { outcome: "selected", optionId });'
assert text.count(assertion) == 1
test.write_text(text.replace(assertion, '      assert.deepEqual(outcome, { outcome: "selected", optionId }, JSON.stringify({ offeredId: optionId, actual: outcome }));'))
PY
cd "$wt/apps/server" || finish 2
env -i PATH="$PATH" HOME="$HOME" TMPDIR="$TMPDIR" T3CODE_HOME="$T3CODE_HOME" CI=1 \
  "$wt/node_modules/.bin/vp" test run \
  src/orchestration-v2/Adapters/AcpAdapterV2.test.ts \
  src/orchestration-v2/Adapters/KiroAdapterV2.test.ts \
  -t "group05|answers Always allow|cancels pending permission requests while interrupting an ACP turn|Kiro permission policy|answers a stale 'this session' approval" \
  --maxWorkers=1 --reporter=json --outputFile="$scratch/results.json" \
  >"$scratch/test.log" 2>&1
test_status=$?
if [ "$test_status" -gt 1 ] || [ ! -f "$scratch/results.json" ]; then
  cat "$scratch/test.log"
  finish 2
fi
python3 - "$scratch/results.json" <<'PY'
import json, sys
result = json.load(open(sys.argv[1]))
checks = [a for t in result['testResults'] for a in t['assertionResults'] if a['status'] in {'passed', 'failed'}]
controls = [a for a in checks if 'group05' not in a['fullName']]
cases = [a for a in checks if 'group05' in a['fullName']]
for a in checks:
    print(a['status'].upper() + ': ' + a['fullName'])
    for failure in a.get('failureMessages', []):
        print(failure.splitlines()[0])
if len(controls) != 6 or any(a['status'] != 'passed' for a in controls) or len(cases) != 2:
    sys.exit(2)
if all(a['status'] == 'passed' for a in cases):
    sys.exit(0)
if all(a['status'] == 'failed' and any('AssertionError' in m for m in a.get('failureMessages', [])) for a in cases):
    sys.exit(1)
sys.exit(2)
PY
finish "$?"

Expected behavior

Select an offered permission option by returning its original string ID unchanged, including any whitespace. T3 pins the upstream v1.21.0 schema and v2 alpha.3 schema; both define PermissionOptionId as a string without a trimming or nonblank restriction, and define the selected outcome as the option chosen from the request. The generated types preserve this contract in packages/effect-acp/src/_generated/schema-v1.gen.ts#L853-L857 and packages/effect-acp/src/_generated/schema.gen.ts#L1042-L1046. This expectation comes from the pinned schemas, without relying on newer protocol additions.

Actual behavior

The shared ACP adapter received a permission request with one allow_once choice and one reject_once choice during an active turn. Answering the approval through respondToRuntimeRequest with decision: "acceptForSession" should select the available one-time choice, as the existing test already checks when no allow_always is offered. With optionId: " opaque-choice ", the handler returned { outcome: { outcome: "selected", optionId: "opaque-choice" } }, which identifies no offered option. With optionId: " ", it returned { outcome: { outcome: "cancelled" } } despite the approval.

Impact

Minor bug or occasional failure

Impact: P2 - A bounded protocol interoperability failure prevents the agent from receiving the permission selection the user made for valid whitespace-bearing IDs.

Observed scope is the shared adapter handler exercised by the existing fake-agent test. Source shows the same selector serves explicit accept, session accept, decline, and automatic decisions, but only the session-accept fallback was exercised with the two failing IDs. Ordinary non-whitespace IDs worked in the controls. No live provider was launched, and no claim is made that a particular published agent currently emits such IDs. Workaround status: unverified; retrying with the same request cannot preserve its ID, and changing the agent's opaque IDs requires agent-side support.

Version or commit

T3 Code commit 59e64eef881632a23f89c4138bcf37f23d92bf93; apps/server package version 0.1.9.

Environment

Node v26.12.1, Git 2.56.0, Python 3.15.2, Vite+ 1.4.0, Effect 4.1.3; macOS arm64. The run used installed lockfile dependencies and a disposable state directory.

Interface: API: ACP session/request_permission, translated through the shared provider adapter and respondToRuntimeRequest.

Earliest failure stage: Core processing

Logs or stack traces

Evidence

Evidence provenance: observed. Local verification: reproduced. Reproduction completeness: complete for the shared adapter handler. Missing fact: no live published agent was checked for whitespace-bearing option IDs.

The completed script exited 1 with this reduced output. Test names abbreviated by the runner have been expanded below from their source labels; no private paths or identities are included.

FAILED: group05 preserves a permission option ID containing surrounding spaces
AssertionError: {"offeredId":" opaque-choice ","actual":{"outcome":"selected","optionId":"opaque-choice"}}
FAILED: group05 preserves a permission option ID containing only whitespace
AssertionError: {"offeredId":" ","actual":{"outcome":"cancelled"}}
PASSED: answers Always allow with the agent's allow-always option
PASSED: answers Always allow with allow-once when the agent offers no allow-always option
PASSED: cancels pending permission requests while interrupting an ACP turn
PASSED: answers a stale 'this session' approval with Kiro's allow_once
PASSED: keeps Autopilot on only for an unrestricted Full access thread
PASSED: never lets a policy approval persist Kiro's workspace-wide allow_always
RESULT: defect reproduced

The exact ID mutation occurs in packages/provider-acp/src/server/adapter.ts#L1355-L1365, where the selected ID is trimmed and an empty result becomes undefined. The response branch in packages/provider-acp/src/server/adapter.ts#L6768-L6775 returns the resulting ID or turns undefined into cancellation.

Workaround

No user-side workaround was verified for an agent that keeps offering the same whitespace-bearing ID.

Restoration check

Run the attached inline script against the changed checkout. Both whitespace-bearing IDs must be returned exactly as offered, both identity cases must pass, and all six ordinary approval, cancellation, and Kiro controls must still pass. The script must exit 0 and print RESULT: expected behavior.

References

Activity

  1. added
    vouch:denounced
    on Nov 13, 2026
  2. maria-rcks commented on Nov 15, 2026

    @maria-rcks
    Collaborator

    Note

    Written by claude-fable-5-2 on behalf of Maria

    Closing: this account is denounced in .github/VOUCHED.td for filing automated issues faster than maintainers can triage them. A fix PR that links this issue is not affected by this close.

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

    vouch:denounced

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions