Skip to content

[PR] fix(opencode-v2): remove permission:allow so ACP tools can be allowlisted by name - #6825

Open
MorningStar0709 wants to merge 16 commits into
ranxianglei:masterfrom
MorningStar0709:fix/opencode-v2-acp-permission-action
Open

MorningStar0709 wants to merge 16 commits into
ranxianglei:masterfrom
MorningStar0709:fix/opencode-v2-acp-permission-action

Conversation

@MorningStar0709

@MorningStar0709 MorningStar0709 commented Nov 15, 2026 •

Copy link
Copy Markdown

Problem

In OpenCode V2, agent permissions cannot allow billion-context ACP tools by their tool name when the tools are registered with options.permission: "allow".

For example, this intuitive config does not expose compress:

permissions:
  - action: "*"
    resource: "*"
    effect: deny
  - action: compress
    resource: "*"
    effect: allow

The only working pattern is the non-obvious wildcard form:

- action: "*"
  resource: "compress"
  effect: allow

See upstream discussion: anomalyco/opencode#64051

Root cause

src/agent/opencode-v2.ts registers bundled ACP tools and conditional manifest tools with:

options: { codemode: false, permission: "allow" }

This permission: "allow" option tells OpenCode that the tool does not need permission checks, but it also prevents the tool name from being used as the permission action in agent configs. OpenCode's permission matcher then requires action: "*" with the tool name as resource.

Change

Remove permission: "allow" from both registration sites so the tools use their own names as the permission action, matching built-in OpenCode tools:

  • src/agent/opencode-v2.ts line 515 (conditional tools from manifest)
  • src/agent/opencode-v2.ts line 558 (bundled V2_BILI_TOOLS)

Tests

Updated two assertions in tests/opencode-v2.test.ts to expect permission to be undefined instead of "allow":

  • line 307
  • line 880

Local verification:

npm run typecheck  # passes
node --import ./tests/preload-test-env.mjs --import tsx --test tests/opencode-v2.test.ts
# 35/38 pass; the 3 failures are pre-existing environment issues unrelated to this change
# (fake proxy header assertions and conditional-tool manifest 404)

Backward compatibility

Users who currently use the action: "*" resource: "compress" workaround will continue to work because action: "*" still matches any tool name placed in resource.

Users who relied on permission: "allow" to bypass all permission checks will now need to explicitly allow the tools in their agent config, which is the intended OpenCode V2 security model.

Fixes #6826

@ranxianglei ranxianglei changed the title fix(opencode-v2): remove permission:allow so ACP tools can be allowlisted by name [PR] fix(opencode-v2): remove permission:allow so ACP tools can be allowlisted by name Nov 15, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重: 不重复 — searched open+closed issues/PRs for the opencode-v2 permission topic; this PR is the only thread on this mechanism. Upstream report lives in the other repo (anomalyco/opencode#64051), which is the bug report this PR fixes. No parallel [PR] thread in the mirror.
标签: 按 2026-11-12 政策不动源 PR 标签(source thread owned by author + automation).

Review

What I verified

  1. Diff is 4 lines: src/agent/opencode-v2.ts:515 + :558 drop permission: "allow" from the tool-registration options; tests/opencode-v2.test.ts:307 + :880 now pin permission === undefined.
  2. The upstream opencode maintainer (in v2: plugin tools cannot be whitelisted by name in agent permissions; only action: "*" works anomalyco/opencode#64051) confirmed the mechanism: options.permission is the permission action name rules match against (tool.options?.permission ?? name), not an allow/deny effect. With permission: "allow", every bili tool is matched under the action allow, so action: compress can never match. The maintainer explicitly said the fix belongs in billion-context: drop the option.
  3. Local verification on the PR head (526bcb7): npm run typecheck clean; tests/opencode-v2.test.ts 38/38 pass (the 3 failures in the PR description are environment-specific — all green here).
  4. Cherry-picked the commit onto current master (2e3cfc9): applies cleanly (the 4 newer master commits touch neither file), tests 38/38 pass there too.
  5. No other lane uses the permission option (grep across src/agent/); the permission?: string type at src/agent/opencode-v2.ts:97 is the host-API surface declaration and is correctly left in place.
  6. CI at time of writing: 33 green / 4 test shards in progress / 12 gated-skip / 0 red.

Regression analysis (existing behavior on the touched paths)

  • Users with no permission rules: no change — the matcher only hides a tool when the last matching rule is deny with resource: "*"; with no rules, tools are visible either way.
  • Users with a deny-all wall: this is the fix — action: compress (and the other ACP tool names) now match.
  • Behavior change (old → new): the permission action name of the bundled ACP tools (compress, decompress, search_context, acp_status, acp_cache, absorb) and the conditional manifest tools (acp_retrieve, acp_rule) changes from allow to each tool's own name. Consequences: (a) the interim workaround action: allow, resource: "*" — recommended in the upstream thread only hours before this PR — stops matching; users who adopted it must switch to tool names; (b) action: "*", resource: "<tool>" keeps working (wildcard action matches any name), confirmed by the upstream maintainer's 2.3.0 test — backward compatible.
  • Security direction: tightened, not loosened — tools are now checked under their own names, matching built-in tools and the intended V2 security model.
  • codemode: false is untouched (separate concern, upstream #50312).

Test validity: the two updated assertions pin exactly this regression — re-adding permission: "allow" fails both. They have teeth. Residual gap: no e2e against a real OpenCode V2 binary with a permissions block (the V2 WS e2e lane is gated and skipped in this run); the upstream maintainer already verified this exact registration shape on 2.3.0, which mitigates it.

Quality (external contribution): clean — 4 lines, minimal, no dead code, no style drift. No rework needed.

八问

  1. 是什么问题:OpenCode V2 里 bili 的 ACP 工具(compress/decompress/…)不能在 agent 的 permissions 里按工具名放行,只有 action: "*" + resource: <工具名> 这种反直觉写法有效。
  2. 什么原因导致的:options.permission 是权限规则匹配的 action 名(不是 allow/deny 效果);插件设了 permission: "allow",所有 bili 工具都按 action allow 匹配,action: compress 之类的规则永远匹配不到。上游 opencode 维护者已确认机制并指明修复应在 billion-context 侧。
  3. 影响范围与严重程度:仅影响 OpenCode V2 且配置了 permissions(尤其 deny-all 墙)的用户;无权限规则的用户不受影响。p2——有可用绕行(通配符写法),核心功能不丢。
  4. 怎么修复的:两处注册点去掉 permission: "allow",让每个工具按自己的名字参与权限匹配,与 OpenCode 内建工具一致。
  5. 是否有回归问题:审过既有行为——无规则用户:不变;deny 墙用户:修复生效(按名放行即可见);采用过 action: allow 临时绕行的用户(上游 thread 当天才推荐,窗口极小):需改用工具名,属有意变更已披露;action: * + resource: <工具> 不受影响。安全方向是收紧不是放松;无 fail-fast 变吞错、无阈值/时序/输出格式漂移。
  6. 是否破坏缓存:不涉及——宿主侧工具注册,不碰 wire/缓存/重试/游标。
  7. 是否改了设计方向:不涉及——无架构变更,是把插件对齐到上游 V2 的权限模型。
  8. 是否引入了新的配置:不涉及。

行为变更披露(旧 → 新):OpenCode V2 中 ACP 工具的权限 action 名从 allow 变为各工具自身名字。原因:permission: "allow" 是对宿主选项的误用(它设的是 action 名而非效果),导致按名放行不可用。采用过 action: allow 临时绕行的用户需改用工具名;action: * + resource: <工具> 写法继续有效。

判定:可合——等剩余 4 个 CI test shard 转绿(目前 0 红;本地定向验证在 PR head 与当前 master 上均 38/38)。合并动作归 owner。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

CI 终态(已实时核实):head 526bcb7 全部 check 完成 —— 37 green / 13 gated-skip / 0 red。审查结论维持:可合,合并动作归 owner。

@MorningStar0709
MorningStar0709 force-pushed the fix/opencode-v2-acp-permission-action branch from 526bcb7 to 214d908 Compare November 15, 2026 15:57
@MorningStar0709

Copy link
Copy Markdown
Author

The latest CI run failed on test (windows-latest, 22, 5) with the same flaky test as shard 1 earlier:

  • Test: tests/issue2929-codex-fold-double-miss.test.ts → #2929: nudge + proxy-tool-round fold keeps re-request/next-turn byte-stable
  • Failure: post-fold re-request and next steady turn diverge before the summary anchor.

This test exercises the proxy/fold cache path (startServer + mock upstream) and does not touch src/agent/opencode-v2.ts. I do not have admin rights to re-run failed jobs on this repo, so I cannot trigger a re-run myself. Could a maintainer please re-run the failed job? If it keeps failing on Windows we should treat it as a pre-existing flaky test unrelated to this PR.

Thanks!

@MorningStar0709

Copy link
Copy Markdown
Author

Update: I ran the failing test locally on Linux to verify it is unrelated to this change, and it also fails here — but with a different precondition error:

✖ #2929: nudge + proxy-tool-round fold keeps re-request/next-turn byte-stable
  AssertionError [ERR_ASSERTION]: scenario miss: no ephemeral nudge in the pre-fold request (inputs[6]) — probe does not cover the production trigger; adjust nudgeGrowthTokens/filler

Command used: node --test --import tsx tests/issue2929-codex-fold-double-miss.test.ts

This confirms the test is sensitive to nudge/filler token boundaries and is failing independently of src/agent/opencode-v2.ts. It needs either:

  • A fix to its filler/nudge calibration, or
  • A skip/mark-as-flaky until it is stabilized

I do not want to modify unrelated tests in this permission fix PR. Could a maintainer please either re-run the job (in case it is timing-flaky) or temporarily skip this test so the PR can land?,timeout:60000}

MorningStar0709 and others added 5 commits November 16, 2026 20:36
…-fixes merge

The ci-fixes merge added the canonical module-map line (ref ranxianglei#6922, correct alphabetical position) while the PR branch already carried a botched duplicate (ref ranxianglei#6944, non-alphabetical position). Keep the canonical ci-fixes entry, drop the duplicate.
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

What I did this run (CI engineer, PR #6825):

The 3 red test lanes all fail on the same inherited test — #2929: nudge + proxy-tool-round fold keeps re-request/next-turn byte-stable (tests/issue2929-codex-fold-double-miss.test.ts:232, scenario miss: no ephemeral nudge in the pre-fold request (inputs[6])). This is a known pre-existing master red (confirmed by the CI master control in #4599), not caused by this PR's diff, which only touches src/agent/opencode-v2.ts + its test (removes permission: "allow" from the two ACP tool-registration sites) and does not touch nudge logic. The PR's own opencode-v2 tests pass in CI (they are not in the failing set).

Per the CI-coordination policy for inherited master failures, I did not fix #2929 in this branch (it is master-level; the master control is re-calibrating the probe anchor PROXY_TOOL_AT=6, which has been stale since #4521 / commit 3197f10a9a, and will converge the fix into ci-fixes). Instead I:

  1. Merged ci-fixes into the PR branch and pushed the final head — sha 3a91f2373b (no [ework:ci-held] marker, per the final-head push discipline).
  2. Resolved the reference/architecture.md duplicate the merge introduced: the PR branch carried a botched entry (responses-system-sections.ts … (#6944), non-alphabetical position) while ci-fixes carries the canonical one (… (#6922), correct alphabetical position). Kept the canonical ci-fixes line, dropped the duplicate.
  3. Reported to CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 (one line) that [PR] fix(opencode-v2): remove permission:allow so ACP tools can be allowlisted by name #6825 is red on inherited codex 命中率问题分析 #2929 (same as [PR] kernel: keep unresolved summary anchors stable across appended turns #6941), ci-fixes merged, sha=3a91f2373b.

The test lane will turn green once the #2929 re-calibration lands in ci-fixes (then a follow-up merge picks it up). No design decision is needed from this side.


结构化八问(中文):

  1. 是什么问题:PR [PR] fix(opencode-v2): remove permission:allow so ACP tools can be allowlisted by name #6825 的 3 条 test lane 红,失败测试均为 #2929: nudge + proxy-tool-round fold keeps re-request/next-turn byte-stable(tests/issue2929-codex-fold-double-miss.test.ts:232)。
  2. 什么原因导致的:master 既有红(继承性失败),非本 PR 引入。codex 命中率问题分析 #2929 是确定性测试,probe 锚点 PROXY_TOOL_AT=6 自 Compression conflict banner (bili v0.1.205, node v24.19.0, win32-x64) #4521(commit 3197f10a9a)起未重新标定,实际 nudge 落在 {3,5,12} 而非预期的 {4,6,8,9};本 PR 的 diff 不触碰 nudge 逻辑。
  3. 影响范围与严重程度:仅阻塞本 PR 的 CI(3 条 test lane 红),不影响 PR 实际代码变更(opencode-v2 permission:allow 移除);PR 自身 opencode-v2 测试全部通过。属 CI 阻塞,非功能缺陷。
  4. 怎么修复的:按 CI 协调政策(继承性失败)将 ci-fixes merge 进 PR 分支并推送最终 head(sha=3a91f2373b),同时解决 merge 引入的 architecture.md 重复行(保留 ci-fixes 规范版本 ref [Bug] Inconsistent system prompt separator in Responses internal re-request breaks cache prefix | [Bug] Responses 内部重请求的系统提示分隔符不一致,破坏缓存前缀 #6922,移除 PR 作者错误版本 ref [PR] fix(responses): share developer segment concatenation between compressed re-request and steady state, fix prefix re-bill | fix(responses): 压缩重请求与稳态共用 developer 段拼接,修复每次折叠后的前缀重计费 (#6922) #6944)。未在本分支修 codex 命中率问题分析 #2929(master 级,由总控重标定后收敛到 ci-fixes)。
  5. 是否有回归问题:无。opencode-v2 变更正确(2 处 tool 注册移除 permission:allow 改为 codemode: false,测试断言同步更新);architecture.md 去重为 docs 修正,无行为影响。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

判定:PR 自身变更正确,CI 红为继承性 #2929,已按政策 merge ci-fixes 并报告总控;待 #2929 重标定进 ci-fixes 后 test lane 转绿,无需本侧决策。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Re-verified live state on head 3a91f2373b (my ci-fixes-merge head from the prior run): the run completed with 3 failed / 0 pending. I fetched all 3 failing job logs — they fail on the same inherited test #2929: nudge + proxy-tool-round fold keeps re-request/next-turn byte-stable (scenario miss: no ephemeral nudge in the pre-fold request (inputs[6]), ERR_ASSERTION), just in different shards than the prior run (now windows 22/4, ubuntu 22/3, ubuntu 24/3; before ubuntu 24/2, ubuntu 22/2, windows 22/5). This is the known pre-existing master red (probe anchor PROXY_TOOL_AT=6 stale since #4521/3197f10a9a), not caused by the ci-fixes merge or the PR's opencode-v2 diff.

No new action taken this run: the #2929 re-calibration is still not in ci-fixes (the master control in #4599 is coordinating the bisect → re-calibrate), and fixing a master-level test in this PR branch is out of scope per the CI-coordination policy. The branch is already converged with ci-fixes (sha 3a91f2373b); once the #2929 fix lands in ci-fixes, a follow-up merge picks it up and the test lanes turn green. Already reported to #4599.


结构化八问(中文):

  1. 是什么问题:head 3a91f2373b 的 3 条 test lane 红(windows 22/4、ubuntu 22/3、ubuntu 24/3),失败测试均为继承的 #2929: nudge + proxy-tool-round fold keeps re-request/next-turn byte-stable。
  2. 什么原因导致的:master 既有红,非本 PR 或 ci-fixes merge 引入。codex 命中率问题分析 #2929 是确定性测试,probe 锚点 PROXY_TOOL_AT=6 自 Compression conflict banner (bili v0.1.205, node v24.19.0, win32-x64) #4521 起未重标定,实际 nudge 落 {3,5,12};本次 3 个 job 日志错误信息逐字相同,仅 shard 不同。
  3. 影响范围与严重程度:仅阻塞本 PR 的 CI(3 条 test lane),不影响 PR 实际变更(opencode-v2 permission:allow 移除);属 CI 阻塞,非功能缺陷。
  4. 怎么修复的:本轮无新动作——上一轮已按政策 merge ci-fixes 并推送最终 head(sha=3a91f2373b),codex 命中率问题分析 #2929 由总控重标定后收敛到 ci-fixes,届时 follow-up merge 即转绿;未在本分支修 master 级测试(政策禁止)。
  5. 是否有回归问题:无。ci-fixes merge 仅带入 architecture.md 规范行(已去重),opencode-v2 变更正确;3 条红 lane 的失败签名与 merge 前完全一致,证明非 merge 引入。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

判定:CI 红为继承性 #2929(已两轮验证,签名逐字一致),分支已收敛 ci-fixes,待总控重标定落地后转绿;无需本侧新动作或决策。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Thanks for the update. A few clarifications on the CI status (verified live just now):

Current state: head 3a91f2373b (my ci-fixes-merge head) — 3 test lanes red: windows 22/4, ubuntu 22/3, ubuntu 24/3. The windows 22/5 lane you mentioned is actually green now. All 3 failing lanes fail on the same test: #2929: nudge + proxy-tool-round fold keeps re-request/next-turn byte-stable (tests/issue2929-codex-fold-double-miss.test.ts).

Why re-running won't help: this is not a flaky/timing test — it's a deterministic failure. The probe anchor PROXY_TOOL_AT=6 in the test has been stale since #4521 (commit 3197f10a9a): the test expects the nudge to land at inputs[6], but the actual nudge now lands at {3,5,12}. Re-running the job will produce the identical failure every time. I confirmed this by fetching the job logs across multiple runs — the error message is byte-identical.

Root cause & fix path: this is a pre-existing master red (confirmed by the CI master control in #4599), not caused by this PR's diff (which only touches src/agent/opencode-v2.ts + its test, removing permission: "allow" from two tool-registration sites — it does not touch nudge logic). The #2929 re-calibration (updating the probe anchor) is being coordinated by the master control and will land in the ci-fixes branch. Once it does, a follow-up merge into this PR branch picks it up and the test lanes turn green.

What I've already done: merged ci-fixes into this PR branch (sha 3a91f2373b), resolved the architecture.md duplicate the merge introduced, and reported to #4599. The branch is already converged with ci-fixes.

So: no re-run needed (it would just fail again), and the fix is already in motion via the master control. The test lanes will turn green once the #2929 re-calibration lands in ci-fixes. Your PR's own changes are correct and verified — the CI red is purely the inherited #2929.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Thanks for confirming the local repro — the error you're seeing (scenario miss: no ephemeral nudge in the pre-fold request (inputs[6])) is byte-identical to what CI shows, which confirms this is the same deterministic #2929 failure, not a platform-specific issue.

On the two options you raised:

Re-run: won't help — the test is deterministic (stale probe anchor PROXY_TOOL_AT=6 since #4521), so every re-run produces the identical failure. I've confirmed this across multiple job logs.

Skip the test in this PR: I'm deliberately not doing this, for the reason you yourself stated — "I do not want to modify unrelated tests in this permission fix PR." The #2929 test is a master-level test (not part of this PR's diff). Skipping it here would (a) modify an unrelated test in a permission-fix PR, and (b) mask a real master regression that affects every PR, not just this one. The right fix is to re-calibrate the probe anchor, which is exactly what the CI master control is doing in #4599.

What's actually happening: the #2929 re-calibration is being coordinated by the master control and will land in the ci-fixes branch. I've already merged ci-fixes into this PR branch (sha 3a91f2373b); once the #2929 fix lands in ci-fixes, a follow-up merge picks it up and all test lanes turn green. This is the standard path for inherited master reds — the fix converges in ci-fixes, not in individual PR branches.

Bottom line: your PR's changes are correct and verified (opencode-v2 tests pass, the diff is clean). The CI red is purely the inherited #2929, which is being fixed at the master level. The lanes will turn green once that fix lands in ci-fixes — no action needed from your side, and no skip needed in this PR.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[opencode-v2] ACP tools registered with permission:"allow" cannot be allowlisted by name in agent permissions

2 participants