fix(acp): forward allowlisted client headers on all ACP paths - #384
Open
rehmanmuradali wants to merge 2 commits into
Open
fix(acp): forward allowlisted client headers on all ACP paths#384rehmanmuradali wants to merge 2 commits into
rehmanmuradali wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes ACP header propagation by ensuring allowlisted client x-* headers are forwarded to agent ACP servers on ACP paths where get_headers(agent) was previously called without explicit request_headers.
Changes:
- Add a fallback in
AgentACPService.get_headers()to use inboundRequest.headerswhenrequest_headersis not provided. - Preserve existing behavior when
request_headersis explicitly passed (including opting out by passing{}).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rehmanmuradali
marked this pull request as draft
July 29, 2026 12:22
rehmanmuradali
marked this pull request as ready for review
July 29, 2026 12:26
Several ACP paths call get_headers(agent) without threading the inbound
client headers, so filter_request_headers(None) returned {} and no
allowlisted client x-* headers reached the agent. Fall back to the
inbound request headers so the existing allowlist forwards them.
Co-authored-by: Cursor <cursoragent@cursor.com>
Assert that omitting request_headers forwards allowlisted inbound x-*
headers (dropping sensitive ones), and that passing {} forwards none.
Co-authored-by: Cursor <cursoragent@cursor.com>
rehmanmuradali
force-pushed
the
fix/acp-forward-client-headers
branch
from
July 30, 2026 06:24
90ddd41 to
775527b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_headers(agent)is called from several ACP paths (send_message_stream,create_task, cancel/interrupt) without threading the inbound client headers.filter_request_headers(None)returned{}, so no allowlisted clientx-*headers ever reached the agent.Test plan
send_message_stream) and confirm allowlisted clientx-*headers now reach the agent.request_headersis explicitly passed.Made with Cursor
Greptile Summary
This PR fixes a header-forwarding gap in the ACP service:
get_headers(agent)was called withoutrequest_headerson several code paths (send_message_stream,create_task, cancel/interrupt), causingfilter_request_headers(None)to return{}and silently drop all allowlisted clientx-*headers.agent_acp_service.py): Whenrequest_headers is None, fall back todict(self._request.headers)before filtering, so the existing security allowlist (x-*prefix,BLOCKED_HEADERSexclusion) now correctly forwards headers on all ACP code paths.test_agent_acp_service.py): Two new unit tests cover the fallback case (no explicit headers → inboundx-*forwarded, credentials blocked) and the explicit-empty-dict case (no fallback triggered, onlyx-request-idremains).Confidence Score: 5/5
Safe to merge — minimal, well-targeted fallback that activates the already-existing security filter on code paths that previously bypassed it entirely.
The fix is four lines in one function, backed by two new unit tests that verify both the fallback and the explicit-override cases. The security allowlist was already correct — the only gap was that it was never reached when callers omitted request_headers. No new untested code paths are introduced.
Files Needing Attention: No files require special attention.
Important Files Changed
get_headers: falls back todict(self._request.headers)whenrequest_headers is None, preserving existing security filtering viafilter_request_headers.Sequence Diagram
sequenceDiagram participant Caller as ACP Caller participant GH as get_headers(agent) participant FR as filter_request_headers() participant RQ as self._request.headers Caller->>GH: get_headers(agent) [no request_headers] Note over GH: request_headers is None GH->>RQ: dict(self._request.headers) RQ-->>GH: raw inbound headers GH->>FR: filter_request_headers(inbound_headers) Note over FR: Allow x-* only, block credentials FR-->>GH: "safe x-* subset" GH->>GH: merge filtered + delegation + auth headers GH-->>Caller: final headers dictReviews (3): Last reviewed commit: "test(acp): cover get_headers inbound-hea..." | Re-trigger Greptile