Skip to content

feat: capture, persist, and strip Agent Firewall correlation headers in AI Bridge#26529

Draft
SasSwart wants to merge 1 commit into
mainfrom
sas/aigov-259-capture-persist-and-strip-boundary-correlation-headers-in-ai
Draft

feat: capture, persist, and strip Agent Firewall correlation headers in AI Bridge#26529
SasSwart wants to merge 1 commit into
mainfrom
sas/aigov-259-capture-persist-and-strip-boundary-correlation-headers-in-ai

Conversation

@SasSwart

Copy link
Copy Markdown
Contributor

Wire the Agent Firewall correlation headers (X-Coder-Agent-Firewall-Session-Id and X-Coder-Agent-Firewall-Sequence-Number) through the AI Bridge interception processor so that each interception is linked to its originating firewall session.

Closes https://linear.app/codercom/issue/AIGOV-259

Changes

Header constants (coderd/aibridge/aibridge.go)

  • HeaderAgentFirewallSessionID and HeaderAgentFirewallSequenceNumber

Recorder struct (aibridge/recorder/types.go)

  • AgentFirewallSessionID *string and AgentFirewallSequenceNumber *int32 on InterceptionRecord

Interception processor (aibridge/bridge.go)

  • Read both headers before CreateInterceptor
  • Strip both headers from the request immediately after reading
  • Pass values to RecordInterception
  • extractAgentFirewallHeaders helper parses the sequence number as int32, logs a warning on invalid input

dRPC translator (coderd/aibridged/translator.go)

  • Map the new fields into RecordInterceptionRequest proto

Upstream safety net (aibridge/intercept/client_headers.go)

  • Strip agent firewall headers in PrepareClientHeaders as defense-in-depth before upstream forwarding

Tests

  • TestExtractAgentFirewallHeaders: parsing edge cases (both present, absent, zero, invalid, overflow)
  • TestPrepareClientHeaders/agent_firewall_headers_are_removed: safety-net stripping

Notes

  • The proto (RecordInterceptionRequest) and DB columns (aibridge_interceptions.agent_firewall_session_id, agent_firewall_sequence_number) were added in AIGOV-252 / AIGOV-260. This PR fills the gap between the HTTP layer and those lower layers.
  • The proto uses int32 (not int64 as the RFC originally proposed). This PR follows the implemented type.
  • Agent firewall headers are intentionally not stripped in aibridged/http.go; they must flow through to the bridge layer where they are read and consumed. The safety-net strip in PrepareClientHeaders catches any residual headers before the upstream SDK call.

Generated by Coder Agents on behalf of @SasSwart

Implementation plan

See the AIGOV-259 plan for the full implementation plan and design decisions.

Prerequisite issues (both Done):

Data flow:
request headerbridge.go reads + strips → InterceptionRecordtranslator.go → proto RecordInterceptionRequestaibridgedserver.go → DB

…in AI Bridge

Wire the Agent Firewall correlation headers through the AI Bridge
interception processor so that each interception is linked to its
originating firewall session.

Changes:
- Add HeaderAgentFirewallSessionID and HeaderAgentFirewallSequenceNumber
  constants in coderd/aibridge.
- Add AgentFirewallSessionID and AgentFirewallSequenceNumber fields to
  the recorder.InterceptionRecord struct.
- Read and strip both headers in the interception processor
  (aibridge/bridge.go) before creating the interceptor, passing the
  values to RecordInterception.
- Map the new fields through the dRPC translator to the proto request.
- Strip Agent Firewall headers in PrepareClientHeaders as a safety net
  before upstream forwarding.
- Add unit tests for header extraction, parsing edge cases, and the
  PrepareClientHeaders safety-net stripping.
@linear-code

linear-code Bot commented Jun 18, 2026

Copy link
Copy Markdown

AIGOV-259

@datadog-coder

datadog-coder Bot commented Jun 18, 2026

Copy link
Copy Markdown

Pipelines

⚠️ Warnings

🚦 3 Pipeline jobs failed

ci | fmt   View in Datadog   GitHub Actions

ci | lint   View in Datadog   GitHub Actions

ci | required   View in Datadog   GitHub Actions

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: ac12872 | Docs | Give us feedback!

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