Skip to content

feat(acp): bridge approval permissions - #538

Merged
delete-cloud merged 1 commit into
mainfrom
feat/acp-approval-bridge
Jun 4, 2026
Merged

delete-cloud merged 1 commit into
mainfrom
feat/acp-approval-bridge

Conversation

@delete-cloud

@delete-cloud delete-cloud commented Jun 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add ACP agent-originated JSON-RPC requests for session/request_permission
  • map internal ApprovalRequest messages into ACP permission requests and submit ACP outcomes back to SessionManager
  • add ADR-0062 and focused stdio/approval tests

Tests

  • uv run pytest tests/acp -k "permission or stdio" -v
  • uv run pytest tests/acp -v
  • uv run pytest tests/cli/test_entrypoint_contract.py -k acp -v
  • uv run ruff check src/coding_agent/acp src/coding_agent/cli/local_runtime.py tests/acp tests/cli/test_entrypoint_contract.py
  • git diff --check -- src/coding_agent/acp/mapper.py src/coding_agent/acp/server.py src/coding_agent/cli/local_runtime.py tests/acp/test_server.py docs/adr/0062-acp-approval-permission-bridge.md .opencode/prompts/tasks/acp-approval-bridge-task-packet.md

Summary by CodeRabbit

  • New Features

    • Added ACP approval permission bridge to handle approval requests through client-initiated permission flows
    • Support for multiple approval outcomes: allow-once, allow-session, and reject
  • Tests

    • Added comprehensive test coverage for permission request behavior and JSON-RPC routing

Add ACP session/request_permission handling for internal ApprovalRequest messages, map ACP outcomes back into submit_approval_response, and route agent-originated stdio JSON-RPC responses by id.

Verification:

- uv run pytest tests/acp -k "permission or stdio" -v

- uv run pytest tests/acp -v

- uv run pytest tests/cli/test_entrypoint_contract.py -k acp -v

- uv run ruff check src/coding_agent/acp src/coding_agent/cli/local_runtime.py tests/acp tests/cli/test_entrypoint_contract.py
@coderabbitai

coderabbitai Bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR implements ACP (Approval Context Protocol) approval bridging for Coding Agent: internal approval requests are converted into ACP session/request_permission JSON-RPC calls sent to the client, client permission outcomes are mapped back into SessionManager.submit_approval_response() calls, and the stdio transport is extended to support bidirectional outbound client calls with response correlation.

Changes

ACP Approval Permission Bridge

Layer / File(s) Summary
Architecture decision and task specification
coding-agent/docs/adr/0062-acp-approval-permission-bridge.md, coding-agent/.opencode/prompts/tasks/acp-approval-bridge-task-packet.md
ADR-0062 documents the bridge design (problem context, solution with stdio client-call facility and request-id correlation, rejected alternatives, and acceptance criteria). Task packet specifies the implementation scope and testing loop policy.
Approval request/response data transformation
coding-agent/src/coding_agent/acp/mapper.py
Mapper imports ApprovalRequest and introduces approval_request_to_permission_params() to build permission request payloads from internal approval objects, permission_outcome_to_approval() to convert ACP outcomes into (approved, feedback, scope) tuples, and _tool_kind() to map tool names to standardized kind categories.
Server protocol and initialization setup
coding-agent/src/coding_agent/acp/server.py (protocol & init)
Extends AcpSessionManager protocol with submit_approval_response(). Updates AcpServer.__init__ to accept optional call_client dependency, adds set_call_client() setter, and refactors mapper imports.
Server-side approval request handling
coding-agent/src/coding_agent/acp/server.py (handle_approval_request)
Implements handle_approval_request() method that validates client infrastructure, calls the ACP client via session/request_permission, maps permission outcomes back to approval fields, and submits responses to the session manager.
Stdio transport client-call infrastructure
coding-agent/src/coding_agent/acp/server.py (run_stdio)
Extends stdio transport with pending-response futures keyed by generated request IDs, implements async call_client() helper that sends JSON-RPC requests and awaits matching responses, updates process_line() to route client responses to waiting futures while passing server requests to normal handling, and adds _is_jsonrpc_response() classifier.
Approval detection in session prompt handler
coding-agent/src/coding_agent/acp/server.py (session/prompt)
Detects incoming ApprovalRequest messages during session/prompt processing and delegates to handle_approval_request() before continuing the prompt loop.
Session runtime integration for approval responses
coding-agent/src/coding_agent/cli/local_runtime.py
Extends LocalCliSessionManager protocol and implements submit_approval_response() in ServerBackedLocalCliSessionManager to delegate to the underlying SessionManager, making the approval-response capability available to CLI execution.
Tests for approval request handling and stdio integration
coding-agent/tests/acp/test_server.py
Expands protocol imports to include approval types, extends FakeManager with submit_approval_response(), adds three permission-request tests validating client callback payloads and response submissions for different outcomes (allow-once/allow-session/cancelled), and adds two stdio integration tests confirming response resolution and error routing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • delete-cloud/Coding-Agent-Loop#95: Introduces SessionManager.submit_approval_response as the runtime bus for consuming approval decisions, which this PR bridges from the ACP protocol layer.

Poem

🐰 A bridge across the JSON-RPC streams so bright,
Where ACP clients grant permissions—or deny outright,
Request IDs courted with futures, futures courted back,
The approval flows bidirectional on its shimmering track!
Thump-thump goes the agent, approvals in sight! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. 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 The title 'feat(acp): bridge approval permissions' accurately describes the main change: implementing ACP bridging for approval permission flows, mapping internal ApprovalRequest messages to ACP permission requests.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/acp-approval-bridge

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 and usage tips.

@delete-cloud

Copy link
Copy Markdown
Owner Author

Local review fallback because CodeRabbit remained pending with only the auto-generated review-in-progress comment.

Manual P1/P2 review scope:

  • agent-originated stdio JSON-RPC request/response correlation
  • ApprovalRequest -> session/request_permission mapping
  • ACP selected/cancelled outcome -> submit_approval_response mapping
  • local CLI session manager runtime method coverage

Result: no actionable P1/P2 findings.

Verification already run locally:

  • uv run pytest tests/acp -k "permission or stdio" -v
  • uv run pytest tests/acp -v
  • uv run pytest tests/cli/test_entrypoint_contract.py -k acp -v
  • uv run ruff check src/coding_agent/acp src/coding_agent/cli/local_runtime.py tests/acp tests/cli/test_entrypoint_contract.py
  • git diff --check -- changed files

@delete-cloud
delete-cloud merged commit 3f68959 into main Jun 4, 2026
1 check was pending
@delete-cloud
delete-cloud deleted the feat/acp-approval-bridge branch June 4, 2026 16:30
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.

1 participant