Skip to content

feat: add no-result permission outcome for extensions (upstream PR #802)#56

Merged
krukow merged 2 commits intomainfrom
coral-lark
Mar 13, 2026
Merged

feat: add no-result permission outcome for extensions (upstream PR #802)#56
krukow merged 2 commits intomainfrom
coral-lark

Conversation

@krukow
Copy link
Collaborator

@krukow krukow commented Mar 13, 2026

Motivation

Upstream copilot-sdk PR #802 adds a no-result permission outcome so extensions can attach to sessions without actively answering permission requests. This is the idiomatic Clojure port.

Approach

When a permission handler returns {:kind :no-result}, the SDK treats it as "this extension declines to answer" rather than a deny:

  • v3 protocol (broadcast): The handlePendingPermissionRequest RPC call is skipped entirely — the extension stays silent and another handler may respond.
  • v2 protocol (RPC callback): A JSON-RPC internal error (-32603) is propagated to the CLI, matching upstream behavior where the thrown error signals no answer was given.

The sentinel value {:result :no-result} (a keyword instead of a map) flows through the internal handle-permission-request! → caller pipeline so both v2 and v3 code paths can distinguish it from a normal permission result.

Key decisions

  • Handles both direct and wrapped forms: Permission handlers may return {:kind :no-result} (direct) or {:result {:kind :no-result}} (wrapped). Both are normalized to the sentinel before reaching callers.
  • Error code -32603 matches the upstream Node.js SDK's internal error semantics for v2 no-result propagation.

Changes

  • specs.clj:no-result added to ::permission-result-kind
  • session.cljhandle-permission-request! returns sentinel for no-result
  • client.clj — v3 handler skips RPC; v2 handler returns error
  • integration_test.clj — Tests for both direct and wrapped no-result on v2
  • API.md — Documents :no-result in permission result examples
  • CHANGELOG.md — Entry under [Unreleased]

Validation

  • 94 tests, 294 assertions, 0 failures
  • bb validate-docs passes
  • Self-reviewed with GPT-5.4 + Gemini 3 Pro in parallel; both findings fixed

Created with GitHub Desktop

Extensions can attach to sessions without actively answering permission
requests by returning {:kind :no-result} from their :on-permission-request
handler.

- v3 protocol: skip handlePendingPermissionRequest RPC call
- v2 protocol: propagate as JSON-RPC internal error (-32603)
- Handle both direct {:kind :no-result} and wrapped {:result {:kind :no-result}}
- Add :no-result to ::permission-result-kind spec
- Add tests for both direct and wrapped no-result on v2 path
- Update API.md and CHANGELOG.md

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 13, 2026 10:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ports upstream copilot-sdk PR #802 by introducing a :no-result permission outcome so extensions can attach to sessions without actively answering permission requests, with protocol-specific behavior for v2 vs v3.

Changes:

  • Add :no-result to permission result specs and document it in the public API reference.
  • Normalize permission handler returns to a {:result :no-result} sentinel in session/handle-permission-request!.
  • Implement protocol-specific handling: v3 skips handlePendingPermissionRequest RPC; v2 propagates -32603 as an error, with integration tests for v2.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/github/copilot_sdk/integration_test.clj Adds v2 protocol integration tests for direct and wrapped :no-result permission handler returns.
src/github/copilot_sdk/specs.clj Extends ::permission-result-kind to include :no-result.
src/github/copilot_sdk/session.clj Normalizes permission handler responses and introduces {:result :no-result} sentinel.
src/github/copilot_sdk/client.clj Implements v3 “skip RPC on no-result” and v2 “return -32603 error on no-result” behavior.
doc/reference/API.md Documents {:kind :no-result} as a permission handler return option.
CHANGELOG.md Adds an Unreleased changelog entry describing the new :no-result outcome and v2/v3 semantics.

- Clarify handle-permission-request! docstring for v2 vs v3 behavior
- Add integration test for v3 permission.requested no-result path
- Add integration test for v3 permission.requested approved path
- Add handlePendingPermissionRequest handler to mock server

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@krukow krukow merged commit 5526263 into main Mar 13, 2026
1 check passed
@krukow krukow deleted the coral-lark branch March 13, 2026 11:23
@github-actions github-actions bot mentioned this pull request Mar 13, 2026
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