Skip to content

fix(acp): let ACP clients answer permission requests instead of always selecting the first option (#5480) - #6265

Open
LeonxLJX wants to merge 1 commit into
OpenHands:mainfrom
LeonxLJX:fix/5480-acp-permission-human-in-loop
Open

LeonxLJX wants to merge 1 commit into
OpenHands:mainfrom
LeonxLJX:fix/5480-acp-permission-human-in-loop

Conversation

@LeonxLJX

@LeonxLJX LeonxLJX commented Oct 27, 2026 •

Copy link
Copy Markdown

HUMAN:

Contributed backend SDK fix addressing issue 5480. Summary below.

AGENT:

Why

See issue 5480.

Summary

  • Change in linked issue 5480

Issue Number

Addresses issue 5480. Required tracking: #6840

How to Test

Per issue reproduction steps.

Video/Screenshots

Backend SDK change - logs/tests suffice.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

Scope: targeted fix for issue 5480. Backend-only change.

Jev-Fast-Audit

⚡ Jev fast audit · estimates · 0.26s · commit d67e879
Strongest signal: No primary concern selected.
Evidence: No primary concern to locate.
Coverage: complete supplied coverage; 4/4 hunks, 1/1 files.

All estimates and evidence
Estimate Likelihood / value Direct evidence
SQL injection 2.0% No direct hunk selected
Command injection 3.0% No direct hunk selected
Weakened authentication 5.0% No direct hunk selected
Weakened authorization 10.0% No direct hunk selected
Contract regression 10.0% No direct hunk selected
Data loss 3.0% No direct hunk selected
Sensitive data disclosure 5.0% No direct hunk selected
Unexpected data transfer 4.0% No direct hunk selected
Credential misuse 4.0% No direct hunk selected
Untrusted instruction authority 4.0% No direct hunk selected
Package source redirection 3.0% No direct hunk selected
Unverified remote execution 2.0% No direct hunk selected
Privileged environment access 3.0% No direct hunk selected
Security assessment bypass 7.0% No direct hunk selected
Prohibited workload 2.0% No direct hunk selected
Primary concern None selected; confidence 85.0% No primary concern to locate

…s selecting the first option (OpenHands#5480)

Add PermissionMode enum (AUTO / ASK) and an optional permission_callback to
_OpenHandsACPBridge. Default remains AUTO (returns options[0]) so existing
headless runs see zero behaviour change. ASK mode with a registered callback
routes the choice to a human-facing front end; without a callback ASK falls
back to AUTO so enabling the mode cannot deadlock a bridge.

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions

Copy link
Copy Markdown
Contributor

📁 PR Artifacts Notice

This PR contains a .pr/ directory with temporary PR-specific documents. The directory will be automatically removed after this PR merges to main through a cleanup PR.

@LeonxLJX

Copy link
Copy Markdown
Author

Hi, the \Validate PR description\ check is failing because the linked issue needs a
eady-for-dev\ label. Could a maintainer please add that label to issue # Thanks!

@LeonxLJX

LeonxLJX commented Nov 4, 2026

Copy link
Copy Markdown
Author

Hey team! @OpenHands/maintainers 👋 All green here, no conflicts, rebased on latest main. Could someone review when you get a chance? Thanks!

@vibewrk

vibewrk commented Nov 27, 2026

Copy link
Copy Markdown

Thanks for picking this up, @LeonxLJX. Are you aiming for an in-process SDK hook or the agent-server approval flow?

The bridge callback could be a starting point for an in-process Python API (if exposed on ACPAgent), whereas agent-server HTTP/WebSocket clients can't register a Python callback and need the event + response contract discussed in #5480.

On the current diff regardless of direction:

  • Callback context: pass tool_call and session_id alongside options so a caller/UI can show what action is being approved.
  • Fail closed in ASK mode: require a callback up front, and if a request reaches ASK without one or the callback raises, return ACP's cancelled outcome instead of falling back to auto-approving options[0].
  • cancelled outcome & validation: allow returning ACP's cancelled outcome (explicitly and on turn/task cancellation, cleaning up pending state), and validate any selected option_id against that request's offered options (allowing a human to intentionally pick an offered reject_* option).
  • Tests: the diff only touches acp_agent.py. Tests for valid/invalid selections, a missing or raising handler, and cancellation mid-wait would help.

The fallback path keeps main's options[0] / literal "allow_once" selection. I proposed splitting the by-kind default fix out in #5480; let me know there if you'd rather fold it in here or leave it for a small standalone PR.

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