Conversation
Docs preview📖 View docs preview for |
Documentation CheckUpdates Needed
Note: Automated review via Coder Agents |
johnstcn
left a comment
There was a problem hiding this comment.
Was the query plan you shared on the current database state or on a synthetic dataset that includes the new indexes proposed here?
There was a problem hiding this comment.
Would it be simpler to inline two nil-able int64s instead of making an embedded struct?
NetworkCallsTotal *int64 `json:"network_calls_count,omitempty"`
NetworkCallsBlocked *int64 `json:"network_calls_blocked,omitempty"`
| // seq 3, so A's window is (0,3) and B's is (3, +inf). The logs at seq 0 | ||
| // and 3 are the interceptions' own LLM-provider calls and must be | ||
| // excluded by the exclusive lower bound. |
There was a problem hiding this comment.
Restates the inline comments below.
| // seq 3, so A's window is (0,3) and B's is (3, +inf). The logs at seq 0 | |
| // and 3 are the interceptions' own LLM-provider calls and must be | |
| // excluded by the exclusive lower bound. | |
| // seq 3, so A's window is (0,3) and B's is (3, +inf). |
Add a "Total/blocked network calls" column to the AIBridge sessions table, rendering per-session total, blocked, and errored call counts as badges plus "No activity" and "Disabled" states. Define the NetworkCalls contract on the codersdk AIBridgeSession type; the DB aggregation and handler population are left as marked TODO touch points. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The AI Gateway sessions table shipped with the network-calls column scaffolded but unpopulated, so every session rendered as "Disabled". Aggregate Agent Firewall egress per session in ListAIBridgeSessions by correlating boundary_logs to each interception's firewall session and sequence window (seq, next_seq). The exclusive lower bound drops the interception's own LLM-provider call; matched_rule IS NULL counts blocked requests. Sessions that never passed through Agent Firewall report a nil summary so the UI keeps rendering "Disabled". Drop the errored counter for now; boundary_logs has no error signal yet. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Move the non-generated frontend changes for network call badges to a separate branch so this PR is backend only. The generated typesGenerated.ts additions remain, as they are produced by make gen alongside the backend changes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
EhabY
left a comment
There was a problem hiding this comment.
A few small comments on the FE, but it looks solid!
| <TableHead className="text-nowrap">Provider</TableHead> | ||
| <TableHead className="text-nowrap">Client</TableHead> | ||
| <TableHead className="text-nowrap">In/Out Tokens</TableHead> | ||
| <TableHead className="w-40"> |
There was a problem hiding this comment.
Why is this header styled differently, shouldn't it be text-nowrap like above without the width limit?
We could also shorten this to fit in like the other titles to Network Calls since the content it self includes total/blocked
| return ( | ||
| <TooltipProvider> | ||
| <Tooltip> | ||
| <TooltipTrigger asChild> |
There was a problem hiding this comment.
Maybe copy the pattern in LastConnectionHead.tsx:13-21 by adding tabIndex={0} to the InfoIcon plus an sr-only "More info" label
Currently there is no way to see why something is disabled using the keyboard (without a mouse)
| return ( | ||
| <TooltipProvider> | ||
| <Tooltip> | ||
| <TooltipTrigger asChild> |
| } from "#/components/Tooltip/Tooltip"; | ||
|
|
||
| interface NetworkCallBadgesProps { | ||
| size?: "xs" | "sm" | "md"; |
There was a problem hiding this comment.
AFAIK this is never used right? If so then let's remove it for now and only add it when there are other consumers
| -- Fetch only the most recent user prompt across all interceptions | ||
| -- in the session. | ||
| SELECT up.prompt | ||
| FROM aibridge_user_prompts up | ||
| WHERE up.interception_id = ANY(sr.interception_ids) | ||
| ORDER BY up.created_at DESC, up.id DESC | ||
| LIMIT 1 |
There was a problem hiding this comment.
Out of scope of this PR: the plan you linked shows the sample query being absolutely hammered by this join. We should probably follow up separately on this.
|
@johnstcn I've updated the link in the PR description to point to a new query plan. This one is against a seeded DB (2k sessions, 240k log lines). The seeded data is perhaps too uniform, but I believe this is still a good estimate. We are introducing some cost. It's only 25% of the cost that you identified in your comment above though. I have a fix in mind, but I'm trying to determine whether its worth forcing this now or if this is a rabbit hole of diminishing returns. |
johnstcn
left a comment
There was a problem hiding this comment.
Let's ship and observe the perf on dogfood.
Add a "Total/blocked network calls" column to the AIBridge sessions table.
Update
ListAIBridgeSessionsquery to calculate network called made and blocked per session. See query plan here.