feat: surface agent firewall correlation in AI Bridge sessions API (#26416)

Add `agent_firewall_session_id` and `agent_firewall_sequence_number`
fields to `AIBridgeThread` in the `GET
/api/v2/aibridge/sessions/{session_id}` response. These fields link each
thread to its agent firewall confinement session so the frontend can
discover the boundary session and compute sequence ranges for
interleaving firewall events within the thread timeline.

The database columns already exist on `aibridge_interceptions`
(migration 000520) and are already selected by
`ListAIBridgeSessionThreads`. This PR surfaces them through the SDK type
and the `db2sdk` conversion.

Depends on #24814

**Naming note:** The RFC uses `boundary_session_id` /
`boundary_sequence_number`, but the codebase standardized on
`agent_firewall_*` naming in the DB migration. The API fields follow the
existing convention.

</details>

> [!NOTE]
> This PR was authored by Coder Agents.
This commit is contained in:
Sas Swart
2026-06-22 15:17:37 +02:00
committed by GitHub
parent 335d6bda1b
commit adad5bdd49
8 changed files with 115 additions and 12 deletions
+9
View File
@@ -15141,6 +15141,15 @@ const docTemplate = `{
"codersdk.AIBridgeThread": {
"type": "object",
"properties": {
"agent_firewall_sequence_number": {
"description": "AgentFirewallSequenceNumber is the firewall sequence number from\nthe root interception. Used to determine the position of this\nLLM request in the firewall event stream. Nil when the request\ndid not pass through the agent firewall.",
"type": "integer"
},
"agent_firewall_session_id": {
"description": "AgentFirewallSessionID links this thread to an agent firewall\nconfinement session. Nil when the request did not pass through\nthe agent firewall.",
"type": "string",
"format": "uuid"
},
"agentic_actions": {
"type": "array",
"items": {
+9
View File
@@ -13489,6 +13489,15 @@
"codersdk.AIBridgeThread": {
"type": "object",
"properties": {
"agent_firewall_sequence_number": {
"description": "AgentFirewallSequenceNumber is the firewall sequence number from\nthe root interception. Used to determine the position of this\nLLM request in the firewall event stream. Nil when the request\ndid not pass through the agent firewall.",
"type": "integer"
},
"agent_firewall_session_id": {
"description": "AgentFirewallSessionID links this thread to an agent firewall\nconfinement session. Nil when the request did not pass through\nthe agent firewall.",
"type": "string",
"format": "uuid"
},
"agentic_actions": {
"type": "array",
"items": {
+8
View File
@@ -1274,6 +1274,14 @@ func buildAIBridgeThread(
if prompts := promptsByInterception[rootIntc.ID]; len(prompts) > 0 {
thread.Prompt = &prompts[0].Prompt
}
if rootIntc.AgentFirewallSessionID.Valid {
id := rootIntc.AgentFirewallSessionID.UUID
thread.AgentFirewallSessionID = &id
}
if rootIntc.AgentFirewallSequenceNumber.Valid {
n := rootIntc.AgentFirewallSequenceNumber.Int32
thread.AgentFirewallSequenceNumber = &n
}
}
// Compute thread time bounds from interceptions.