Skip to content

fix(agent-mention): accept upstream /opencode and /oc trigger aliases - #1537

Closed
seonghobae wants to merge 9 commits into
mainfrom
fix/opencode-agent-mention-oc-alias
Closed

fix(agent-mention): accept upstream /opencode and /oc trigger aliases#1537
seonghobae wants to merge 9 commits into
mainfrom
fix/opencode-agent-mention-oc-alias

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Root cause

Owner-flagged (on .github#1506): "@opencode-agent라고 부르면 호출되는 기능도 인터넷 가이드에는 /oc라고 나와있기 때문에 이 점도 확인해 보는 게 좋겠습니다" — the internet's own guide for invoking OpenCode uses /oc, not @opencode-agent.

Verified against OpenCode's actual public documentation (open-code.ai/en/docs/github): its GitHub Action integration triggers on /opencode or /oc in a comment, not an @mention. This repo's scripts/ci/agent_mention_router.py — the single source of truth for mention detection, imported by both the comment-triggered router and agent_mention_sweep.py's scheduled organization sweep — only recognized @opencode-agent. A commenter following OpenCode's own public docs would type /oc and silently trigger nothing.

Fix

Widen the existing "opencode-agent" entry in MENTION_PATTERNS to accept /opencode and /oc as aliases of the same request (word-boundary-anchored, case-insensitive, same as the existing @opencode-agent pattern), and add the same substrings to agent-mention-router.yml's cheap contains() pre-filter so the job isn't skipped before the precise regex ever runs. No new agent identity, no downstream dispatch-logic change — /opencode//oc resolve to the same "opencode-agent" key as before.

Verification

  • tests/test_agent_mention_router.py: 8 new parametrized cases — /opencode//oc (plus case variants /OC, /OpenCode) dispatch correctly; longer tokens that merely start with /oc//opencode (/occupied, /oceanography, /opencode-docs) correctly do not match.
  • coverage run -m pytest tests && coverage report --show-missing: 2135 passed, 1 skipped, 100% coverage on scripts/ci/ (agent_mention_router.py: 275/275 statements, 112/112 branches).
  • interrogate: 100% docstrings.
  • python3 -c "import yaml; yaml.safe_load(open('.github/workflows/agent-mention-router.yml'))" → OK.
  • Targeted: tests/test_agent_mention_sweep.py, test_agent_mention_workflow_contract.py, test_agent_mention_review_regressions.py, test_agent_mention_idempotency.py — 25 passed, confirming the sweep and workflow contract are unaffected.

Developer experience

Anyone following OpenCode's own public documentation can now successfully trigger a re-review, instead of the comment silently doing nothing.

User experience

No user-facing change beyond the new accepted trigger phrases — purely additive.


Generated by Claude Code


Devin Review

Summary by CodeRabbit

  • 새 기능

    • 댓글에서 @opencode-agent뿐 아니라 /opencode/oc 명령어로도 동일한 에이전트 요청을 실행할 수 있습니다.
    • 유사한 문자열이나 URL 경로가 의도치 않게 명령어로 인식되지 않도록 구분이 강화되었습니다.
  • 문서

    • 새로운 호출 방식이 변경 로그와 자동화 안내 문서에 반영되었습니다.
  • 테스트

    • 새 명령어 별칭, 경계 사례 및 주요 PR 처리 예외 상황에 대한 검증이 추가되었습니다.

Owner-flagged gap: OpenCode's own GitHub Action documents /opencode
and /oc as its trigger phrases, but this repo's agent_mention_router.py
only recognized the locally-invented @opencode-agent mention. A
commenter following OpenCode's public docs would silently trigger
nothing.

Widen the existing "opencode-agent" MENTION_PATTERNS regex to accept
/opencode and /oc as aliases of the same request (agent_mention_sweep.py
picks this up transitively since it imports the same matcher), and add
the same substrings to agent-mention-router.yml's cheap pre-filter.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KPmJErfkcHer4UVEgrQxUX
devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor Author

exact-head-path-policy failed on this head (6b46f40b) with the identical signature as #1506's own tracked issue: FAIL: opencode required workflow bootstrap must not depend on required-workflow event payload fields / test_strix_quick_gate: 1 failure(s). This is the same pre-existing base-branch awk job-boundary bug in scripts/ci/test_strix_quick_gate.sh, unrelated to this PR's diff (which only touches agent_mention_router.py, agent-mention-router.yml, its tests, and CHANGELOG.md). Canonical fix is #1506. Not re-running — same known base-branch-red failure. Keeping this PR watched; should clear once #1506 merges.


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

Next included review available in 37 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 844fd8c1-abd2-408b-bb29-27316fa98678

📥 Commits

Reviewing files that changed from the base of the PR and between ed7cbdc and 1b36c5b.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • scripts/ci/agent_mention_router.py
  • tests/test_agent_mention_router.py
📝 Walkthrough

Walkthrough

Changes

OpenCode 별칭 라우팅

Layer / File(s) Summary
별칭 인식 및 라우팅
.github/workflows/agent-mention-router.yml, scripts/ci/agent_mention_router.py, tests/test_agent_mention_router.py, docs/automation/review-agent-comment-invocation.md, CHANGELOG.md
@opencode-agent/opencode/oc를 추가했습니다. 대소문자 변형과 경계 조건을 테스트합니다. 문서와 변경 로그를 갱신했습니다.

스케줄러 동작 검증

Layer / File(s) Summary
스케줄러 조건 및 REST 조회 검증
tests/test_pr_review_fix_scheduler.py, tests/test_pr_review_merge_scheduler.py
DIRTY PR의 건너뛰기 조건을 검증합니다. 워크플로 이름 조회의 페이지네이션, 빈 이름 필터링, 권한 오류의 빈 맵 반환, HTTP 502 전파를 검증합니다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: 🔵 Low · up to ed7cb

The new aliases can be detected inside URL query strings, so a trusted commenter posting a link containing '/oc' or '/opencode' could unintentionally invoke the review agent; the PR is otherwise mergeable, but this bounded automation risk should be fixed or explicitly accepted.

Suggested reviewers: cursoragent

Sequence Diagram(s)

sequenceDiagram
  participant PR 댓글
  participant agent-mention-router.yml
  participant agent_mention_router.py
  participant opencode-agent
  PR 댓글->>agent-mention-router.yml: `@opencode-agent`, /opencode 또는 /oc 포함
  agent-mention-router.yml->>agent_mention_router.py: 라우팅 조건 통과
  agent_mention_router.py->>opencode-agent: opencode-agent 요청 전달
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 76.92% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 4 files. (3 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 /opencode/oc 트리거 별칭을 지원하도록 에이전트 멘션 처리를 수정한 주요 변경 사항을 정확하고 간결하게 설명합니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 76.92% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 4 files. (3 skipped: 3 unsupported.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/opencode-agent-mention-oc-alias

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae
seonghobae enabled auto-merge (squash) September 1, 2026 02:39
@opencode-agent
opencode-agent Bot disabled auto-merge September 1, 2026 04:59
main currently sits at 99% coverage (fail_under = 100), not caused by this
branch: pr_review_fix_scheduler.py's inspect_pr() has two unexercised
skip paths for a conflicted PR (draft, and not-authorized-for-repair), and
pr_review_merge_scheduler.py's fetch_workflow_names_by_check_suite_rest()
(added by #1541, never directly tested) has no coverage for a non-
permission RuntimeError propagating, a row with a check_suite_id but no
workflow name being skipped, or pagination continuing past a full page.
Verified the same 99% gap reproduces on origin/main alone before writing
these tests. Carried onto this branch so #1537 can pass its own 100%
coverage gate without waiting on a separate fix PR to merge first; also
opening that fix directly against main.
devin-ai-integration[bot]

This comment was marked as resolved.

… match

Devin review finding on #1537: the mention regex's negative lookbehind
excluded a preceding letter/digit/underscore/hyphen but not a preceding
slash, so a documentation link like https://opencode.ai/docs (where
"/opencode" immediately follows the scheme's own "//") satisfied the
lookbehind and could launch an unintended review. Added "/" to the
excluded lookbehind character class, verified against the existing
accept/reject cases plus the new URL-substring regression.

Also updates docs/automation/review-agent-comment-invocation.md's operator
guide (Devin's second finding) to list /opencode and /oc alongside
@opencode-agent, matching the now-accepted trigger phrases.
devin-ai-integration[bot]

This comment was marked as resolved.

Devin review finding on #1537: the prior fix's slash-exclusion lookbehind
applied to the whole @opencode-agent|/opencode|/oc alternation, so a
maintainer separating two requested agents with a bare slash and no space
(@cwl-noema-review/@opencode-agent) silently lost the OpenCode request --
the same lookbehind that correctly rejects a documentation-link false
positive like https://opencode.ai now also rejected the intended @mention.
Split the lookbehind per Devin's suggested fix: the slash exclusion applies
only to the bare /opencode and /oc forms; @opencode-agent keeps its
original lookbehind, unaffected by a preceding slash.
devin-ai-integration[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

…eparator

Devin review finding on #1537 (second round): the previous fix exempted the
@opencode-agent form entirely from the slash-preceded exclusion so that
@cwl-noema-review/@opencode-agent (a bare-slash separator) would still
dispatch OpenCode. That reopened the exact false-positive class the first
fix closed, just for the @ form instead of the /opencode //oc forms: a
trusted comment sharing a link like https://youtube.com/@opencode-agent, or
even an ordinary path segment like docs/@opencode-agent, would satisfy the
same shape and launch an unintended review.

Replaced the blanket exemption with a narrow third alternative:
/@opencode-agent is recognized only when the slash is immediately preceded
by the other pattern's exact literal mention text, @cwl-noema-review, not
by an arbitrary preceding word. This keeps the deliberate separator case
working while URL paths and ordinary text no longer qualify.
devin-ai-integration[bot]

This comment was marked as resolved.

CodeRabbit review finding on #1537: the bare /opencode and /oc forms'
slash-exclusion lookbehind did not also exclude a preceding "=", so a URL
query string such as https://example.com/?next=/opencode or ?next=/oc
still matched and could dispatch an unintended review. Added "=" to the
excluded lookbehind character class alongside the existing letter/digit/
underscore/hyphen/slash exclusions.
…tor literal

The @cwl-noema-review/@opencode-agent bare-slash separator alternative
checked only that the slash immediately preceding /@opencode-agent was
preceded by the literal text @cwl-noema-review, without checking that
occurrence's own left boundary. Invalid pasted text embedding the Noema
mention in a larger token (foo@cwl-noema-review/@opencode-agent,
docs/@cwl-noema-review/@opencode-agent, an email-like local part) still
dispatched an unintended OpenCode review.

Reported directly by the repository owner with exact reproduction and a
suggested direction; verified the owner's literal suggested regex still
failed one of their own listed cases (docs/@cwl-noema-review/@opencode-agent)
because it omitted "/" from the excluded lookbehind class. Fixed by matching
the whole @cwl-noema-review/@opencode-agent literal under the same
left-boundary exclusion already used by the standalone @opencode-agent
alternative, verified against the full existing accept/reject matrix plus
the three new cases before touching the source file.

Full suite: 2246 passed, 1 skipped, 21 subtests passed. 100% coverage and
100% docstrings maintained.
@seonghobae
seonghobae enabled auto-merge (squash) September 1, 2026 05:46

Copy link
Copy Markdown
Contributor Author

@opencode-agent review exact head 1b36c5b0dcdb0e70cc3e7aa17aeed7497b3aa720. The invalid combined-separator false-positive is fixed with a full bounded @cwl-noema-review/@opencode-agent alternative and direct negative regressions for word/path/email-like prefixes; all visible review threads are resolved. Auto-merge is enabled. Do not reuse predecessor-head evidence.

Copy link
Copy Markdown
Contributor Author

Superseded by #1558 after #1546 advanced protected main. Before salvage, the router, workflow, router-test, and invocation-doc base blobs were proven byte-identical between this PR's protected base and current main@5686de41660d51a7a7f22b8840dfa6ccfe5ff3f1. #1558 reapplies only those reviewed alias-related blobs on the exact current-main tree and deliberately excludes this branch's unrelated scheduler-coverage additions and stale CHANGELOG ancestry. No checks/reviews transfer.

@seonghobae seonghobae closed this Sep 1, 2026
auto-merge was automatically disabled September 1, 2026 06:18

Pull request was closed

seonghobae added a commit that referenced this pull request Sep 3, 2026
built and CI-green, genuinely unreachable pending the sandbox

Corrected an initial wrong instinct first: naruon's own "noema_agent.py"
looked like a DDD naming collision with the CI review agent's Noema, but
docs/CWL-MASTER-CONTEXT.md explicitly defines Noema as one shared agent
runtime across three consumers (CI review agent, naruon's do-anything
agent, wardnet's AI SOC quarantine sandbox) -- owner-confirmed per
naruon#1527. Checked the master context before concluding two same-named
components were separate, per this session's own established lesson from
an earlier mistake of exactly that kind.

Found: naruon already has a real, tested, CI-green agent + plugin-
registry system (services/noema_agent.py, services/agent_registry.py,
four open PRs #1527/#1486/#1516/#1537, none authored by either active
peer session) matching the platform plan's own documented registry
architecture almost exactly. The confirmed gap: nothing in the API or
frontend layer ever calls it -- the agent, registry, and manifests are
mutually consistent and fully tested but completely unreachable, and have
been since the agent's original commit two months ago.

This connects directly to item 6: the master context has this agent
running inside quarantine-sandbox-runtime, which a peer session is
separately, actively building (still early-stage, confirmed via direct
coordination) -- wiring the agent to a real trigger before that sandbox
exists would ship an unsandboxed, writeback-capable LLM agent against the
documented design, not merely ship an incomplete feature. Not implemented
this tick pending that dependency.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
seonghobae added a commit that referenced this pull request Sep 3, 2026
…in Review)

commits/{sha}/status only reflects the legacy Status API, not GitHub's
Checks API that every workflow in this org actually posts through.
Re-checked with commits/{sha}/check-runs: metadata-only gate evaluation
fails on all 4 (expected — real code changes, not eligible for that
script's fast path, and already excluded from this org's own failed-check
enumeration). noema-review genuinely failed on #1527/#1537 — pulled the
job log for #1527 and logged a new, concrete review-failure case (a JSON
repair failure) for item 23's aggregation ask. strix was cancelled on
#1486/#1537, consistent with the already-documented repo-wide
concurrency-group starvation, not a new finding.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

2 participants