Repository navigation
feat(proxy): label each Bob reply with the IBM backend that served it - #975
Conversation
The Bob IDE sends its task id in the X-Task-Id request header, not in the body. The proxy read only metadata.taskId (Bob Shell), so every IDE conversation fell back to the content-hash session. That hash changes at compaction, so one IDE conversation split into several sessions. What changed: - session.Explicit takes optional host ids, tried last, after the header and the metadata fields. The precedence stays in one rule. - The proxy reads X-Task-Id only on the Bob model route (POST /inference/v1/chat/completions on the Bob gateway). Other routes and other agents are unchanged. - The pipeline, expand repair, observe-mode billing and the wire recorder all use the same resolved id. - newRecCtx drops its unused request parameter. Data dependence: metadata only (a request header). Works at every storage level. docs/data-dependence.md "Session tracker" row updated. Tested: 8 proxy tests and unit tests. The new-behavior tests fail on main with the derived hash and pass with the change. Live: two Bob IDE 2.3.0 chats became two sessions named by their Bob task ids. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Vitaly Zabershinsky <[email protected]>
The proxy already removes region and region_domain from Bob's profile reply, and already labels Bob traffic as "bob". Both were tested only at the helper level. These tests pin them through the real Bob route, with the IDE's full profile shape. What the tests cover: - GET /admin/v1/profile: every field is kept except region and region_domain, including teams. - The client's Accept-Encoding never reaches the upstream on that call, and the client gets plain JSON. - Other paths and methods (teams, POST profile, profile/x) are not changed. - A non-200 reply and a body of an unknown shape pass through unchanged. - The IDE and Bob Shell User-Agents give the agent "bob"; Claude Code and Codex keep their labels. No production code changes. Live: Bob IDE 2.3.0 answered through CG with no other proxy in front. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Vitaly Zabershinsky <[email protected]>
BEHAVIOR CHANGE (Bob route only), needs a human developer's yes before merge: a Bob dashboard row now books its cache writes, so cost_usd on a row with 1-hour writes rises on a deployment that has a price for Bob's tier (1h tokens are priced at the input rate x 2.0). The local Bob plugin has no Bob price, so its cost_usd stays 0. Bob's usage block is OpenAI Chat shaped but also carries cache-write fields. The shared parser (providerusage.Parse) reads only cached_tokens on that shape, so a Bob cold call was booked as 20,319 fresh tokens and 0 writes, and /api/cachestate gave ttl_s 300 for a prefix that lives an hour. - bobUsage (proxy/bobusage.go) reads cache_write_tokens and the 1-hour split after the shared parser, and sets fresh = prompt - read - write. It fails open on any odd shape. - It runs only when up.path == bobModelPath. providerusage.Parse and its callers (cheapmodel, dash, keepalive) are unchanged. Tested: unit tests on real Bob blocks (cold, warm), proxy-level tests on the JSON, SSE and buffered paths (row 4/0/20315/20157/12, ttl_s 3600), and isolation tests: the same block on /openai and /anthropic is booked as before, and the shared parser's output is pinned. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Vitaly Zabershinsky <[email protected]>
The expand repair marks restored content kept-verbatim under a session id. On Bob's route that must be the X-Task-Id session, the id the pipeline uses, or offload compacts the content back into its marker. The new test fails with the raw header id. docs/design.md now lists X-Task-Id among the explicit session ids. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Vitaly Zabershinsky <[email protected]>
IBM serves Bob's model route from 2 backends that count tokens differently (about 17,600 against 11,100 for the same request). A preset comparison is only valid on one backend, and the proxy recorded none. On Bob's route only, it now labels each reply A, B or other, from 2 marks that must agree: the reply id's shape and whether the usage block has cache_write_tokens. Measured on 9 real replies on 2026-11-09. - The label goes in a new dashboard column, backend, and a /stats counter, bob_backend. The id is never stored or logged. - other is the alarm: a new or changed mark logs one WARN per shape, with only the id's first 4 characters, its length and 2 flags. - Replies with no id or no usage (Bob's router calls) get no label. Those with an id but no usage are counted apart, in id_no_usage, to measure how often it happens before deciding how to label them. - A stream whose chunks carry 2 ids is other. It should never happen. - Fail open: any parse problem gives no label. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Vitaly Zabershinsky <[email protected]>
vz-ibm
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (claude, user of @vz-ibm) | Claude Code 2.1.316 | offload-review skill, @vz-ibm's session | fresh | 1 of 2 | 1 of 2 | e3af6e349ab0 |
blocking |
Verdict: blocking
Findings
- proxy/bobusage.go:218 — the
otheralarm is not "once per new shape". A changed backend B uses up all 8 WARN slots, and later shapes log nothing.- What fails: the dedupe key is
prefix|len|cacheWrite, andprefixis the first 4 characters of the id. Backend B's ids are random letters and digits (nb3x7kLm…), so 2 B replies almost never share a prefix. Suppose IBM changes B, for example it addscache_creation_token_details, or moves to 24-character ids. Then every B reply isotherwith a new key. The first 8 B replies each log one WARN (8 lines for 1 change). After that,len(bobShapeSeen) == bobShapeMaxfor the life of the process. A later, different change, for examplechatcmpl-withoutcache_write_tokenson A, logs no WARN. The PR says "otheris the alarm" and "logscg.bob_backend_unknownonce per new shape". Neither holds for B. - Second part of the same defect: the key and the log line leave out
creationDetailsandmixedIDs. A mixed-id A stream logsprefix=chat len=45 cache_write=true provider_fields=true. That is exactly the shape of a good A reply, so the operator cannot see why it isother. The PR says of mixed streams: "If it ever happens, we want to see it". The log does not show it. - Proof: trace with 2 B replies whose marks are
{id: "nb3x7kLm2PzR8tYv4WcJ1sQ", usage, creationDetails}and{id: "Qa9Z…", usage, creationDetails}.bobBackendgivesotherfor both (line 407:!m.creationDetailsis false).bobWarnPrefixgivesnb3xandQa9Z. The keys arenb3x|23|falseandQa9Z|23|false. Both are new, so both log. This repeats until 8 keys exist. Then line 221 makesfreshfalse for every key.TestBobRouteUnknownShapeWarnsOnceAndCountsonly uses achatcmpl-id, whose prefixchatis constant, so no test sees this. - Fix: key the dedupe on the shape class, not on id characters. For example:
hasPrefixA,len,alnum,cacheWrite,creationDetails,mixedIDs. Keep the 4-character prefix in the log line only. Addcreation_detailsandmixed_idsto the WARN. Add a test: 3 B-shapedotherreplies with different random ids log 1 WARN, and a later A-shapedotherstill logs 1 WARN.
- What fails: the dedupe key is
Non-blocking
metrics/metrics.go:1103and thestats_golden_test.gocomment list the labels as "A, B, other and none". The map also hasid_no_usage. Update the 2 comments.proxy/bobusage.go:195ResetBobBackendForTestis exported from a non-test file. Aexport_test.goor a lower-case name would keep it out of the package API.dash/redact.go:94:backendOfand its comment sit between thesourceOfdoc comment andsourceOf. Sogo docgivessourceOf's long comment tobackendOf, andsourceOfhas none. MovebackendOfbelowsourceOf.proxy/proxy.go:1989: the observe path callsexplicitSessionOfagain on the post-transform body, not theexplicitSessfrom line 1293. The result is the same today, because the transform does not touchmetadata. One value would match the comment at line 1292 ("Once, so … use one id").- An expand round counts again in
/stats, and the row keeps the last round's label. A round with no usage after a round with usage overwrites the label (line 2201/2292 path), for example with"". The PR names this under Known limits. I note it only so the reader knows the row label can be""on a request where/statscounted anA.
What I checked
- Read the full diff
354fcb32..e3af6e34, all 5 commits, including the 2 stacked commits of #967 (session fromX-Task-Id, Bob cache-write usage) and every new test file:proxy/bobbackend_test.go,bobusage_test.go,bobsession_test.go,bobprofile_test.go,dash/backend_test.go, and the changes insessionrec_test.go,dash_test.go,stats_golden_test.go,promexport_coverage_test.go,session_test.go. - Fail open:
bobUsagereturnsbaseon any missing, non-integer, negative or inconsistent field.bobMarksOfgives empty marks on non-JSON, an empty body or an array.bobWarnPrefixis safe for""and for a cut UTF-8 rune (QuoteToASCII). The label never changes a request or a response byte. - Route scope:
bob := up.path == bobModelPathinserve;explicitSessionOfreturns the bare header on other routes. In hosted modeupstreamForkeepsstatic.path(proxy/tenancy.go:716), so the check holds there too. - Session precedence:
session.explicitappends host ids after header and metadata.ExplicitStrictpassesnil.BodyOptsgets the resolved id aso.Sessionand re-resolves it to the same id. ThealiasandgraceAliasIDstay the content hash. The expand repair, the observe record andnewRecCtxall use the same id. - Spliced stream: traced
sniffer.bytes()and gjson'sparseObjecton a truncated"id":"chatcmpl-01:parseStringfails, so no partial id is noted. The test over 167 offsets covers this. - Dashboard: the INSERT has 92 columns and 92 placeholders. The new column is in
additiveColumns, so the read-only shim and the migration both cover old files.requestColsandscanRequestmatch.backendOfallow-lists the label. - No id leaks: the id is held in
bobMarksfor one call. Only the label, the 4-byte prefix (always shorter than the id) and the length reach a log or a column. /statsis behindStatsTrusted, so the process-wide counts across tenants are operator-only.- Docs:
docs/data-dependence.md,docs/design.md,docs/reference/reference.mdmatch the code. The behavior change and how to turn it off are at the top of the PR. - I did not run Go builds or tests (not approved, Go not installed).
vz-ibm
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (claude, user of @vz-ibm) | Claude Code 2.1.316 | offload-review skill, @vz-ibm's session | fresh | 2 of 2 | 1 of 2 | e3af6e349ab0 |
blocking |
Verdict: blocking
Findings
- proxy/bobusage.go:219 — the "once per new shape" WARN keys on the random start of a B id, so one changed backend fills all 8 slots and hides every later shape
- What fails: backend B ids are 23 random letters and digits. Suppose IBM changes B so that its replies become
other. For example, B starts to sendcache_write_tokens, or B ids become 24 characters. Each B reply then has a different first 4 characters. So each reply makes a new keyprefix|len|cache_write. The first 8 replies log 8 WARN lines for one shape. After that,len(bobShapeSeen) == bobShapeMax, so the process never logs a WARN again. A later, truly new shape (for example, a change to backend A) logs nothing. - The docs promise something else.
docs/reference/reference.mdsays "logscg.bob_backend_unknownonce per new shape".docs/data-dependence.mdsays "one warning per new shape". - Proof:
key := prefix + "|" + strconv.Itoa(len(m.id)) + "|" + strconv.FormatBool(m.cacheWrite)(line 219).prefix = bobWarnPrefix(m.id)(line 218) isid[:4]. For a B-style id that is random.fresh := !dup && len(bobShapeSeen) < bobShapeMax(line 222) stops all logging once 8 keys exist.TestBobRouteUnknownShapeWarnsOnceAndCountsdoes not catch this, because it sends the same canary id twice. - Also: the key leaves out
creationDetailsandmixedIDs. These 2 marks can also make a replyother. So 2 shapes that differ only in them share one WARN, and the WARN line cannot say why the reply isother. - Fix: key the dedup on the shape class, not on id characters. Use: has the
chatcmpl-start, the id length, whether the id is all letters and digits,cacheWrite,creationDetailsandmixedIDs. Keep logging the 4-character prefix if you want, but leave it out of the key. Logcreation_detailsandmixed_idstoo. Add a test that sends 9 or moreotherreplies with different random 23-character ids and the same marks, and expects exactly 1 WARN. Then send one more reply with a different shape and expect a second WARN.
- What fails: backend B ids are 23 random letters and digits. Suppose IBM changes B so that its replies become
Non-blocking
dash/redact.go:86-96: the newbackendOfdoc comment sits right belowsourceOf's doc comment, with no blank line between them. Sogo docjoins both comments ontobackendOf, andsourceOfhas no doc. MovebackendOfwith its comment above thesourceOfcomment block, or put it aftersourceOf.- No test covers a Bob SSE reply on the advertised (tools) path, or on the splice path (
searchOn). The code on those paths is the samestreamRecOn(..., bob)and line 2307 call, so the risk is low. The PR text says "all 3 reply paths" are covered. The tests cover stream-through JSON and SSE, and buffered JSON only. /statsreturns{}whenh.agg == nil(proxy/proxy.go:2790). Sobob_backendis not "always present" in that case, although the metrics comment says it is. This is true only for a handler with no aggregator. The shipped binary always has one.bobMarksOfparses each Bob reply a second time. On SSE it converts the window of up to 128 KiB to a string and splits it into lines. This is a small cost on Bob's route only. It is acceptable now. A later change could reuse the event list fromparseSSEUsageWhy.- This diff also holds the 4 commits of #967 (
X-Task-Idsession, Bob cache writes). Their behavior changes are named at the top of #967, not at the top of #975. I did not check whether a human developer approved them. That approval must be on #967 before either PR merges.
What I checked
- Read
CLAUDE.md, the PR body of #975, the top of #967, and every line ofgit diff 354fcb32..e3af6e34(30 files, all 5 commits), including all new test files. - Session:
explicitSessionOfis used for the pipeline (reqInfo.session), the expand repair, the observecg:bin:record, and the wire recorder (newRecCtx)./compact(line 909) and/expand(line 3016) still read onlyx-context-guru-session. That is correct, because they are not the Bob route. The resolved id goes back into apply aso.Session, andsession.Explicitgives the same result when it runs again. Host ids come last insession.explicit, so Claude Code and Bob Shell ids are unchanged.ExplicitStrictpassesnil.safeExplicitstill guardsX-Task-Id. In hosted mode,session.Scopedstill scopes the id to the tenant.up.pathandstatic.pathare the same in hosted mode (tenancy.go:716), so thebobflag is correct there. - Grace alias and dash alias: both still derive with an empty explicit id, so a Bob IDE session's alias is the content hash. This matches the new comments.
- Usage:
bobUsagefails open on every bad field (type, sign, write > prompt, 1h > write). It runs only whenup.path == bobModelPath.providerusage.Parseis unchanged, and the cheapmodel and keep-alive callers do not change. Keep-alive pings never run on the OpenAI provider (canPing), so Bob pings do not need the Bob parser. - Backend label: it is set on all 3 reply branches in
serve, also when there is no usage.Usage.BackendreachesEvent.Backendincapture.finish.backendOflimits the stored values toA,Borother. The INSERT has 92 columns, 92 placeholders and 92 values (my count, base was 91/91/91).requestColsandscanRequestboth gainedbackend. The additive migration has an entry for the column. Archive deletes rows by session, so a new column does not affect it. - Cut window: with gjson v1.18.0,
parseStringreturnsok=falseon an unterminated string, so a cut id in the head is not read. The tail's first partial line does not start withdata:. This agrees with the 167-offset test. - Log safety:
bobWarnPrefixlogs at most 4 bytes, always fewer than the whole id, escaped to ASCII. No reply text is logged. - Fail open: no new path can change the request or block the reply. The label code runs after the bytes go to the client.
- I did not run Go builds or tests. Live tests are not approved for this review.
The alarm deduped on the id's first 4 characters. Backend B ids are random, so every reply of one changed backend looked like a new shape: 8 of them used every slot, and a later, really different change logged nothing. It now keys on the kind of shape: the chatcmpl- start, the id length, letters and digits only, and the 3 usage marks. The WARN names each mark, so a mixed-id reply is told apart from a good A reply. Also: backendOf moved below sourceOf, so go doc gives each its own comment; the reset hook is no longer exported; 2 comments list the fifth counter, id_no_usage. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Vitaly Zabershinsky <[email protected]>
Round 1: repliesBoth reviewers found the same bug. Fixed in R1-1 and R2-1: the alarm deduped on the id's random first letters, so one changed backend used up every slot. Confirmed.
Non-blocking, fixed:
Non-blocking, no change:
|
The deep test on 2026-11-10 (58 real Bob requests) showed the rule was too strict. Backend B ids are not always 23 characters of letters and digits: a 22-char id, and ids with - or _, were seen. 14 real B replies were labelled other. Bob's "security" helper call (a chatcmpl- id with no cache fields) gave 2 more. B is now an id that does not start with chatcmpl-, with no cache-write fields; length and characters are not checked. The cache-write mark held on every request: all 24 A replies had it, no B reply did. The named helper models (security, router) get no label. Coding tiers (premium, standard, fast) keep theirs. Replayed on all 158 real requests: no A or B label moves, the 14 B replies become B, the 18 helper replies get none, and none is other. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Vitaly Zabershinsky <[email protected]>
vz-ibm
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (claude, user of @vz-ibm) | Claude Code 2.1.316 | offload-review skill, @vz-ibm's session | resumed | 2 of 2 | 2 of 2 | 8a22c9ae5292 |
blocking |
Verdict: blocking
Findings
- proxy/bobusage.go:227-230 — the alarm key still splits one kind of shape by id length and characters, and
8a22c9aesays those vary on backend B- What fails:
8a22c9aestops checking B's id length and characters, because real B ids vary: 22 and 23 characters, some with-or_. But the dedupe key fromc637e43astill haslen(m.id)andbobAlnum(m.id). Suppose IBM changes B, for example B starts to sendcache_creation_token_details. Then every B reply isother. Its key isfalse|<len>|<alnum>|false|true|false. With the variation seen on 2026-11-10, one change gives at least 4 keys: 22 or 23 characters, each alnum or not. So one change logs at least 4 WARNs and uses 4 of the 8 slots. If B lengths vary more than this sample shows, one change fills all 8 slots, and a later change logs nothing. This is the round-1 defect (R1-1, R2-1) again, in a smaller form. - Proof: the rule now says, at line 109: "B ids vary in length and characters … so only what B lacks is checked". The key at lines 227-230 is
HasPrefix(chatcmpl-) | len | alnum | cacheWrite | creationDetails | mixedIDs. Trace 2 B replies withcreationDetails: true: idnb3xQ7kLm2PzR8tYv4WcJ1s(23, alnum) givesfalse|23|true|false|true|false. Idnb3x-7kLm2PzR8tYv4WcJ_(22, not alnum) givesfalse|22|false|false|true|false. They are 2 keys and 2 WARNs for one change.TestBobBackendAlarmIsOncePerKindOfShapeNotPerIDuses only 23-character alnum ids, so it does not see this. - Fix: remove
lenandalnumfrom the key. Keep them in the WARN line, where they help an operator. The key is then the facts the rule uses:chatcmpl-start,cacheWrite,creationDetailsandmixedIDs. In the test, give the 20 changed-B replies different lengths (for example 20 to 25) and some-or_, and expect 1 WARN.
- What fails:
Round-1 findings
- R1-1 and R2-1 (dedupe on the id's random first letters): fixed in
c637e43a. The key no longer holds id characters. The WARN namescreation_detailsandmixed_ids, and the new test checksmixed_ids=true. Finding 1 above is about8a22c9ae: it makeslenandalnumnoise for B, and the key still uses them. - R1 and R2 non-blocking,
backendOfdoc placement: fixed.sourceOfnow has its own comment, andbackendOfhas its own (dash/redact.go:86-109). - R1 non-blocking, the 2 comments that list 4 labels: fixed (
metrics/metrics.go:1103,stats_golden_test.go:37). - R1 non-blocking, exported
ResetBobBackendForTest: fixed. It is nowresetBobBackendForTest, and its only caller is inpackage proxy(bobbackend_test.go:134). - R2 non-blocking items that the author did not change (
/statswith no aggregator, no SSE test on the tools or splice path, the second parse, #967's approval): the author's reasons are correct. I accept them. - R1 non-blocking items on the observe
explicitSessionOfcall and on expand rounds: the author did not reply to the observe item. It is non-blocking, and today the result is the same.
Non-blocking
- The PR description is out of date after
8a22c9ae. "The rule" table still says B is "23 letters and digits". "How it was tested" still says 22- and 24-character ids areother. Neither mentions the helper rule (security,routerget no label). A human approves this PR from that text. Please update it. - The B rule is now 2 absences. A reply is B when its id does not start with
chatcmpl-and the usage has no cache-write fields. So a third backend with any other id format and no cache-write fields is labelled B with no alarm. Before8a22c9ae, the length and character checks gave some protection. The 2026-11-10 data supports the change. Please add this to Known limits, next to the line about a new OpenAI-style backend that looks like A. - The helper rule has unit tests only (
bobBackendwithhelper: true, andbobMarksOfon the model name). No test sends asecurityreply through Bob's route and checks the row andbob_backend.none. The parts are simple, so the risk is low.
What I checked
- Last review: round 1,
e3af6e349ab0a0ee0ce70a6ed0c158abcf842653, 2026-11-09T14:11:57Z - New commits read: 2
c637e43afix(proxy): the Bob backend alarm logs once per kind of shape8a22c9aefix(proxy): the Bob backend rule accepts real B ids and skips helpers
- Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files). I also read the current PR body.
- New items since my last review:
- Author comment "Round 1: replies" (2026-11-09T14:25:45Z). I checked each reply against the code. See "Round-1 findings".
- Commit
c637e43a: reviewed. It fixes R1-1 and R2-1 and the 3 non-blocking items. - Commit
8a22c9ae: reviewed. It loosens the B rule and adds the helper rule. It has no reply comment on the PR. Finding 1 and 2 non-blocking points come from it.
- Read
git diff e3af6e34..8a22c9aein full (6 files) and the code around it: all ofbobBackend,bobMarksOf,bobNoteBackendandbobWarnPrefix, anddash/redact.go:80-112. - Classifier table: with the new rule, each of the table rows gives the expected label.
chatcmpl-+ 14 B characters staysother, because it has no cache write. A helper returns""before any other check, so it never logs a WARN. It counts asnoneand not asid_no_usage, because it has usage. - WARN fields: the log line has 5 flags (
alnum,cache_write,creation_details,mixed_ids,provider_fields). This agrees with "5 yes/no flags" indocs/data-dependence.md. The pinned WARN text inTestBobRouteUnknownShapeWarnsOnceAndCountsagrees with the new field order. No id or reply text goes into the key or the log, only the 4-character prefix. - Fail open: the new code only reads the reply. It does not change a request or a reply byte.
- I did not run Go builds or tests. Live tests are not approved for this review.
vz-ibm
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (claude, user of @vz-ibm) | Claude Code 2.1.316 | offload-review skill, @vz-ibm's session | resumed | 1 of 2 | 2 of 2 | 8a22c9ae5292 |
blocking |
Verdict: blocking
Earlier findings
- R1-1 (alarm dedupe keyed on random id letters): fixed in
c637e43a. The key is nowchatcmpl- start | len | alnum | cache_write | creation_details | mixed_ids. The WARN names all 5 flags.TestBobBackendAlarmIsOncePerKindOfShapeNotPerIDsends 20 B ids that differ and expects 1 WARN, then a different shape and expects a second WARN, then checksmixed_ids=true. I traced it against the code, and it holds after8a22c9aetoo: those B marks havecreationDetails, so they are stillother. - R2-1: the same defect, fixed by the same commit.
- My non-blocking notes: the
id_no_usagecomments, theResetBobBackendForTestexport and thebackendOfplacement are all fixed. I accept the author's reasons for the other 2 (the observe-path second call and the expand-round label). - R2 non-blocking notes: I accept the author's replies. The
/stats{}case applies only to a handler with no aggregator. #967's approval belongs on #967.
Findings
- PR #975 body and docs/reference/reference.md:194 — they still describe the old B rule. The person who must approve this behavior change reads a rule that the code no longer runs.
- What fails: commit
8a22c9aechanges the rule in 2 ways. The PR body does not say so:- B is now "not
chatcmpl-, and no cache-write fields". Length and characters are not checked any more (proxy/bobusage.go:217). - Replies whose
modelissecurityorrouternow get""(bobusage.go:206,:145-148). Before this commit, asecurityreply with achatcmpl-id and no cache fields wasother.
- B is now "not
- The PR body still says:
- "
B: The id is 23 letters and digits…" - "If IBM changes an id format or a field, the reply is
other, neverAorB." - "the id's length, and 2 true/false flags"
- "
""(none): No id, or no usage block"
- "
- All 4 are now false.
reference.md:194says "noneis a reply with no id or no usage (Bob's router calls)". It now also counts helper replies that have usage.- Why it matters:
- CLAUDE.md requires the PR top to name the old and the new behavior for a human's yes.
- The alarm now covers less. A new backend or a changed B id format with no cache-write fields is labelled
Bwith no WARN. Before, it wasother. A preset comparison "on B only" can then mix 2 backends without anyone knowing. That trade may be right: the 2026-11-10 data shows 14 real B replies that were labelledother. But it is a decision, and the PR must state it.
- Proof:
git diff e3af6e34..8a22c9ae -- proxy/bobusage.goremovesbobIDLenBand thebobAlnumcheck frombobBackend.gh pr view 975(updated 2026-11-10T06:44:58Z) still shows the 23-character rule table and the 9-reply capture as the only evidence. - Fix:
- Update the rule table, the
otherparagraph, the log-line description (5 flags) and the "What we found" table (add the 58-reply capture: B ids of 22 and 23 characters, with-/_; helper models). - Add to Known limits: "A new backend with a non-
chatcmpl-id and no cache-write fields reads asB, with no alarm." - Update
reference.md:194for the helper case.
- Update the rule table, the
- What fails: commit
Non-blocking
proxy/bobusage.go:261-265: the dedupe key still holdslen(m.id)andalnum. But commit8a22c9aesays that B ids vary in both. If B changes (for example, it addscache_creation_token_details), its replies of length 22 and 23, with and without-/_, give up to 4 keys for one change. That is 4 of the 8 slots. The bound is real, and the slots do not run out on the lengths seen. If the lengths spread wider, the round-1 defect comes back. Think about leaving out length and alnum when the id does not start withchatcmpl-.bobMarksOfsetshelperwhen any chunk namessecurityorrouter. It never clears it. That is right for a real stream. Note that a helper reply that has an id but no usage still counts inid_no_usage, so that counter also includes helpers. The comment atbobusage.go:179-182says it measures "a backend that stopped sending usage".TestBobMarksTreatOnlyTheNamedHelpersAsHelperstestsbobMarksOfonly. No route-level test shows that asecurityreply gets""on the row and adds 1 tonone. The unit test covers the logic, so the risk is low.
What I checked
- Last review: round 1,
e3af6e349ab0a0ee0ce70a6ed0c158abcf842653, 2026-11-09T14:00:56Z - New commits read: 2
c637e43afix(proxy): the Bob backend alarm logs once per kind of shape8a22c9aefix(proxy): the Bob backend rule accepts real B ids and skips helpers
- Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
- New items since my last review:
- Reviewer 2's round-1 review (2026-11-09T14:11:57Z). Its finding 1 is the same as mine and is fixed. Its non-blocking notes and the author's replies are covered above.
- The author's "Round 1: replies" comment (2026-11-09T14:25:45Z). I checked each claimed fix in the diff. All are present.
- Commit
8a22c9ae, which is not in the replies comment. I reviewed it in full. Finding 1 comes from it. - The PR body (updated 2026-11-10T06:44:58Z). It is stale. See finding 1.
- Read the full
git diff e3af6e34..8a22c9ae(292 lines, 7 files) andproxy/bobusage.goaround each change:bobBackend,bobMarksOf,bobNoteBackend, and the key and the WARN. - The classifier table: the 22/24-character and
-/_ids are nowB. Achatcmpl-id with B usage is stillother. A B id with cache fields is stillother. A mixed-id stream is stillother. Helpers are"". All match the code. TestBobRouteUnknownShapeWarnsOnceAndCounts: the pinned WARN line matches the new field order (prefix, len, alnum, cache_write, creation_details, mixed_ids, provider_fields).- Fail open is unchanged. The new
modelread is metadata, anddocs/data-dependence.mdnames it. - I did not run Go builds or tests (not approved, Go not installed).
The rule stopped checking B's id length and characters, since real B ids vary in both. The alarm key still split shapes by them, so one changed backend with varying ids logged up to 6 WARNs. The key now holds the chatcmpl- start and the 3 usage marks. The WARN line still shows the length and characters for an operator. The test now uses ids of varying length and characters, as real B ids have. docs/reference/reference.md: helper calls count as none, and a new B-like backend reads as B with no alarm. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Vitaly Zabershinsky <[email protected]>
Round 2: repliesBoth findings are fixed. They both come from my rule change in R1-1: the PR body and
R2-1: the alarm key still split one kind of shape by id length and characters. Correct: an inconsistency in my own change. Fixed in
Checks
The live resultIn a rerun on 2026-11-10 (8 chats with deferral off and 8 on, real coding tasks, all on backend A, by this label), the label gave 49 A, 17 B, 0 |
vz-ibm
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (claude, user of @vz-ibm) | Claude Code 2.1.316 | offload-review skill, @vz-ibm's session | resumed | 2 of 2 | 3 of 3 | cc25b9df484c |
approve |
Verdict: approve
Findings
None.
Earlier findings
- R2 round 2, finding 1 (the alarm key still held id length and
alnum): fixed incc25b9df. The key atproxy/bobusage.go:228-231is nowchatcmpl- start | cache_write | creation_details | mixed_ids. These are exactly the factsbobBackenduses to giveother, apart fromhelper, which never reaches theotherbranch. The WARN line still logslenandalnum. The test now uses ids of 22, 23 and 24 characters (22+i%3) from an alphabet with-and_. All 20 replies get one key, so the test expects 1 WARN, and it would fail on the old key. - R1 round 2, finding 1 (the PR body and
reference.md:194described the old B rule): fixed. I read the current PR body in full. The behavior-change block names the helper rule and the B-like trade-off. The rule table, theotherparagraph (5 flags), "What we found" (the 158-request capture) and Known limits all match the code.reference.md:194now counts helper calls asnoneand states the B-like trade-off. This also fixes my round-2 non-blocking items on the PR body and Known limits. - R1 round 2, non-blocking dedupe key note: fixed by the same commit.
- Round-1 findings (R1-1, R2-1): they stay fixed.
- The other non-blocking notes (a route-level test for a
securityreply,id_no_usagealso counting a helper reply that has an id and no usage) are still open. They are small. I agree that they need not block.
Non-blocking
- "How it was tested", line 1 of the PR body still says "22- and 24-character ids" without the result. After
8a22c9aethose ids areB, notother. A reader can guess the old result. Add "(nowB)". bobNoteBackendcounts a helper reply that has an id but no usage inid_no_usage(bobusage.go:215-217). Today'ssecurityreplies have usage, so this does not happen yet. If it does,id_no_usagewould also include helpers, but the comment atbobusage.go:179-182says it measures backends that stopped sending usage. Reviewer 1 noted this first. I checked the code and agree.
What I checked
- Last review: round 2,
8a22c9ae5292c6e6fe596adb077161a58a53b74c, 2026-11-10T07:49:05Z - New commits read: 1
cc25b9dffix(proxy): the Bob alarm key holds only the facts the rule uses
- Read in full: 4 reviews, 2 comments, 0 inline comments (from the three files). I also read the current PR body in full.
- New items since my last review:
- Reviewer 1's round-2 review (2026-11-10T07:49:31Z). Its finding 1 (stale PR body and reference) is fixed. I checked the body and
reference.mdmyself. Its non-blocking notes are covered above. - The author's "Round 2: replies" comment (2026-11-10T07:52:53Z). I checked each claimed fix against the diff and the PR body. All are present. The "live result" paragraph (49 A, 17 B, 0
other) is a measurement report. I cannot check it from the code, and it does not change the review. - Commit
cc25b9df: reviewed in full (3 files, 52 diff lines), andbobNoteBackendaround the change.
- Reviewer 1's round-2 review (2026-11-10T07:49:31Z). Its finding 1 (stale PR body and reference) is fixed. I checked the body and
- Trace: 2 changed-B replies with
creationDetails: true, idsnb3xQ7kLm2PzR8tYv4WcJ1s(23, alnum) andnb3x-7kLm2PzR8tYv4WcJ_(22, not alnum). Both now give the keyfalse|false|true|false, so 1 WARN. Achatcmpl-id with no usage marks givestrue|false|false|false, a second key and a second WARN. This matches the test. - No id characters go into the key. The log still gets only the 4-character prefix, the length and 5 flags. This matches
docs/data-dependence.md. - Fail open is unchanged. The change is only in the warning's dedupe key.
- I did not run Go builds or tests. Live tests are not approved for this review.
vz-ibm
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (claude, user of @vz-ibm) | Claude Code 2.1.316 | offload-review skill, @vz-ibm's session | resumed | 1 of 2 | 3 of 3 | cc25b9df484c |
approve |
Verdict: approve
Earlier findings
- R1 round 2, finding 1 (the PR body and
reference.md:194described the old B rule): fixed.- The behavior-change block at the top now names the helper rule. It also says that a B-like backend raises no alarm.
- The rule table, the
otherparagraph (5 flags) and "What we found" (the 158-request capture) now match the code. - Known limits states the B-like trade-off, and it also names the hard-coded helper models.
reference.md:194now counts helper calls asnoneand states the B-like trade-off.
- R2 round 2, finding 1 (the alarm key still split one shape by id length and
alnum): fixed incc25b9df.- The key is now
chatcmpl- start | cache_write | creation_details | mixed_ids. These are the facts the rule uses. - The WARN line still logs
lenandalnum. - This also fixes my round-2 non-blocking note on the same point.
- The key is now
- My round-2 non-blocking notes:
id_no_usagealso counts helper replies with no usage, and no route-level test sends a helper reply. The author made no change. Both are low risk. I accept that. - R2 round-2 non-blocking notes (the stale PR body, the B-like limit, the helper test): the first 2 are fixed by the same body update. The third is the same as my note above.
- All round-1 findings stay fixed.
Findings
None.
Non-blocking
- In the PR body, "How it was tested" still lists "22- and 24-character ids" with the cases that do not match. Since
8a22c9aethose ids areB, and the classifier test expectsB. One line of the body could say so. proxy/bobusage.go:194bobShapeMax = 8, but 13 kinds of key can reach the alarm. 8 of them are mixed-id kinds, and mixed ids should never happen, so in practice the cap is not reached. A cap of 16 (all 4-flag keys) would make "once per kind" hold in every case, at no real cost.
What I checked
- Last review: round 2,
8a22c9ae5292c6e6fe596adb077161a58a53b74c, 2026-11-10T07:49:31Z - New commits read: 1
cc25b9dffix(proxy): the Bob alarm key holds only the facts the rule uses
- Read in full: 4 reviews, 2 comments, 0 inline comments (from the three files)
- New items since my last review:
- Reviewer 2's round-2 review (2026-11-10T07:49:05Z). I checked its finding 1 against the code. It is fixed in
cc25b9df. Its non-blocking notes are covered above. - The author's "Round 2: replies" comment (2026-11-10T07:52:53Z). I checked each claimed fix in the diff and in the PR body. All are present. The live result it reports (49 A, 17 B, 0
other) is the author's own run. I did not repeat it. - Commit
cc25b9df, reviewed in full (52 diff lines, 3 files). - The PR body (updated 2026-11-10T07:52:53Z), read in full.
- Reviewer 2's round-2 review (2026-11-10T07:49:05Z). I checked its finding 1 against the code. It is fixed in
- Traced
TestBobBackendAlarmIsOncePerKindOfShapeNotPerIDagainst the new key:- The 20 changed-B ids (22 to 24 characters, some with
-or_, all withcreationDetails) all givefalse|false|true|false. That is 1 WARN. - The
chatcmpl-id with no cache write givestrue|false|false|false. That is a second WARN. - The mixed-id A reply gives
true|true|true|true. That is a new key, so its WARN logsmixed_ids=true.
- The 20 changed-B ids (22 to 24 characters, some with
- I counted the keys that can reach the alarm. Mixed ids give 8 keys. A
chatcmpl-id with no cache write gives 2 (creation details on or off). A non-chatcmpl-id with cache-write fields gives 3. That is 13 kinds against a cap of 8. See the second non-blocking note. bobAlnumis still used, by the WARN line, so the change leaves no unused code.- Fail open is unchanged. The change touches only the log dedupe key.
- I did not run Go builds or tests (not approved, Go not installed).
|
Integrator note: the owner added this PR to v0.7.4 (2026-11-12). It conflicts with main, and it has no CodeQL run on its head. Please merge |
|
Integrator note: the owner approved the behavior change on 2026-11-12 ("975 approve"): each Bob reply gets a backend label ( |
Bring the branch up to date with main. #967 is now merged as a squash, so the old #967 commits on this branch overlap with main. The Bob backend label now lives behind the agent interface: - agent.Usage has a Backend field. Bob's ReadUsage sets it. - The marks, the rule, the counters and the alarm moved to agent/bob. - The proxy reads the label for every reply, with or without usage. - The tests of the marks moved to agent/bob. Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5 <[email protected]>
|
@vz-ibm: the integrator merged main into this PR (b0bca53). Main's #1029 moved all Bob logic behind |
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (claude, user of @amiddavid) | Claude Code 2.1.322 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 4 of 4 | b0bca531d3b6 |
blocking |
Verdict: blocking
Findings
- docs/data-dependence.md:228 — the merge edits the generated page by hand. The row file does not have the Bob backend text, so CI fails and the next regeneration deletes that text.
- What fails: main's #1090 made
docs/data-dependence.mda generated page. Its source is one row file per feature. The merge kept the PR's new sentences ("Bob's model route has at least 2 backends … only the/statscounts exist.") in the page. It did not add them todocs/data-dependence/features/billed-token-and-cache-time-records.md. That file still ends at "…works the same at every storage level." - Result 1: CI
build-testfails at this head.TestGeneratedPageIsUpToDate(internal/datadep/datadep_test.go:21) compares the page with the generator output. - Result 2: the next
go run ./cmd/gen-datadepon main (any later PR) silently removes this PR's data-dependence statement from the page. CLAUDE.md requires that statement for a feature. - Proof:
git diff b5037247..HEAD --statchangesdocs/data-dependence.mdand no file underdocs/data-dependence/.grep -rl "bob_backend\|backend label" docs/data-dependence/gives no match.- CI run 43211140657, job
build-test:--- FAIL: TestGeneratedPageIsUpToDate … docs/data-dependence.md is out of date with docs/data-dependence/. Run: go run ./cmd/gen-datadep. It is the only failing test in that job.
- Fix: append the new sentences to the body of
billed-token-and-cache-time-records.md, then rungo run ./cmd/gen-datadep(make datadep). Check that the page diff against main is only this paragraph.
- What fails: main's #1090 made
Earlier findings
- R1-1, R2-1 (alarm dedupe on random id letters): stay fixed. The port keeps the key
chatcmpl- start | cache_write | creation_details | mixed_ids(agent/bob/usage.go:240-243). - R2 round 2, finding 1 (key held
lenandalnum): stays fixed. Same lines.TestBobBackendAlarmIsOncePerKindOfShapeNotPerIDstill uses ids of 22 to 24 characters with-and_. - R1 round 2, finding 1 (stale PR body and
reference.md): stays fixed.reference.md:194is unchanged by the merge. - Round-3 non-blocking notes (mine and reviewer 2's): the "22- and 24-character ids" line in "How it was tested" and the
bobShapeMax = 8cap are unchanged. Still non-blocking. - R1 round 1, exported reset helper: it is exported again as
bob.ResetBackendForTest. The PR body says why: tests in packageproxyneed it across the package boundary. I accept that.
Non-blocking
agent/bob/usage.go:18-22:Bob.ReadUsageis no longer a pure reader. Each call moves process-wide counters and can log a WARN. Today only the proxy calls it, once per reply. A second host of the library, or a second call on the same reply, would count twice. One line in theagent.Agentdoc (or onReadUsage) would warn the next host author.proxy/proxy.go:2420-2427:if ok { u = agentU } else { u.Backend = agentU.Backend }is followed at once by a secondif ok { … } else { … usage.Backend = u.Backend }. Oneif okwould do. Behavior is correct.readAgentUsagenow runs on every reply on every route, also with no usage. Foragent.Baseit returnsbase, so non-Bob routes keep their reading (TestNonBobRouteRecordsNoBackendcovers both transports). Cost is one interface call. Fine.
What I checked
- Last review: round 3,
cc25b9df484cf1756a8d52dc90b1198e5e832f18, 2026-11-10T08:08:11Z - New commits read: 1 on the PR side.
git log cc25b9df..HEAD ^b5037247gives onlyb0bca531(Merge origin/main into feat/bob-backend-label). The other commits incc25b9df..HEADare main's own commits, already reviewed on their PRs. I reviewed the PR's full diff against the new base:git diff b5037247..HEAD, 22 files, +868/−38. - Read in full: 6 reviews, 5 comments, 0 inline comments (from the three files). I also read the current PR body in full.
- New items since my last review:
- Integrator comment 2026-11-12T07:13:24Z (merge main, run a new round): done by
b0bca531; this is the round. - Integrator comment 2026-11-12T09:07:53Z (owner approved the behavior change, "975 approve"): noted. The behavior-change block at the top of the PR body names it.
- Integrator comment 2026-11-12T11:45:35Z (Bob logic moved to
agent/bob; review the agent move): I reviewed the port in full. See below. - PR body section Port behind the agent interface: each of its 6 points matches the code.
- Integrator comment 2026-11-12T07:13:24Z (merge main, run a new round): done by
- The port:
agent/bob/usage.go:bobMarksOfnow also returns the usage block. OldReadUsagetook the JSONusagewithoutPresent; new code requiresPresent.readUsagereturnsbasefor an absent or empty block either way, so token results do not change. The 6 existingusage_test.gocases now stripBackendand still compare the counts.- The rule, the marks, the counters, the key and the WARN fields are the same as at
cc25b9df. proxy/agentusage.go:Backendgoes in and out. A panic in the agent givesbase, withBackend"". Fail open holds.TestReadAgentUsageTakesOnlyTheTokenCountsFromTheAgentcovers the new field througheveryFieldSet.proxy/proxy.go: all 3 reply branches setusage.Backend, with and without usage (lines 2310, 2402, 2430).streamRecOn(2843-2850) and the buffered path (2417-2431) take onlyBackendfrom the agent when the shared parser found no usage.agis Bob only onbob.ModelPath(agent/bob/bob.go:29).proxy/dashcapture.go:697copies the label to the event. The dashboard column, migration, insert, scan andbackendOfare unchanged from round 3./statsfillsbob_backendfrombob.BackendCounts().- Tests:
agent/bob/backend_test.gohas the rule, marks, prefix and alarm tests.proxy/bobbackend_test.gohas the route, stats, router, buffered, non-Bob and cut-offset tests. I read both in full.
- CI at
b0bca531: CodeQL, DCO, purego, build, trivy pass.build-testfails, only onTestGeneratedPageIsUpToDate(finding 1). - I did not run Go builds or tests (not approved, Go not installed).
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (claude, user of @amiddavid) | Claude Code 2.1.322 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 4 of 4 | b0bca531d3b6 |
blocking |
Verdict: blocking
Findings
- docs/data-dependence.md:228 — the merge edited the generated page by hand. The row file does not have the Bob backend text. CI
build-testfails on it.- What fails: since #1090,
docs/data-dependence.mdis built from the row files bygo run ./cmd/gen-datadep. This PR adds the Bob backend sentences only to the built page. The row filedocs/data-dependence/features/billed-token-and-cache-time-records.mdstill ends at "…so this works the same at every storage level." So:internal/datadepTestGeneratedPageIsUpToDatefails.- The next person who runs the generator deletes this PR's data-dependence text without noticing. CLAUDE.md requires the data-dependence statement for this feature.
- Proof:
git diff b5037247..HEAD --stat -- docs/data-dependence/is empty. Onlydocs/data-dependence.mdchanged.- CI on
b0bca531, jobbuild-test(run 43211140657):--- FAIL: TestGeneratedPageIsUpToDate/datadep_test.go:22: docs/data-dependence.md is out of date with docs/data-dependence/. Run: go run ./cmd/gen-datadep/FAIL github.com/rossoctl/context-guru/internal/datadep. It is the only failing test in that log.
- Fix: add the Bob backend sentences (from "Bob's model route has at least 2 backends…" to "…only the
/statscounts exist.") to the body ofdocs/data-dependence/features/billed-token-and-cache-time-records.md. Then rungo run ./cmd/gen-datadepand commit both files. This changes only docs, so the label behavior and its tests do not change.
- What fails: since #1090,
Earlier findings
- R1-1 and R2-1 (round 1, the alarm deduped on random id letters): stay fixed.
agent/bob/usage.go:432-435keys on thechatcmpl-start,cacheWrite,creationDetailsandmixedIDsonly. - R2 round 2, finding 1 (the key held id length and
alnum): stays fixed. Same key.TestBobBackendAlarmIsOncePerKindOfShapeNotPerIDmoved toagent/bob/backend_test.gowith its 22-24 character ids that include-and_. - R1 round 2, finding 1 (stale PR body and
reference.md): stays fixed.reference.md:194and the PR body match the code. - R1 round 1, non-blocking (exported reset function): it is exported again as
bob.ResetBackendForTest. The reason is right:proxytests are in another package now, and the PR body says so. I accept it. - R1 round 3, non-blocking (
bobShapeMax = 8against 13 key kinds): not changed. It is still only a log cap, so it need not block. - My round-3 non-blocking notes (the "22- and 24-character ids" line in "How it was tested", and
id_no_usagealso counting a helper with an id and no usage): not changed. Both are still small.
Non-blocking
agent/agent.go:26-29: theReadUsagecontract says "base is that reading", and it describes only a token correction. After this PR the host calls it on every reply, also when the shared parser read no usage (proxy/proxy.go:2420,:2844).Bob.ReadUsagenow also has side effects: it moves the process-wide counters and can log a WARN. A later second caller (for example, a host's own model call that reads usage on Bob's route) would count each reply twice inbob_backend. One sentence in the interface doc would prevent that: "The host calls it once per reply, with or without usage. It may set Backend."proxy/proxy.go:2421-2431has twoif okblocks in a row on the sameok. One block would be easier to read. Not a defect.
What I checked
- Last review: round 3,
cc25b9df484cf1756a8d52dc90b1198e5e832f18, 2026-11-10T08:08:07Z - New commits read: 1 on the PR branch,
b0bca531"Merge origin/main into feat/bob-backend-label". It brings in 82 commits of main. I did not review main's own commits. I compared the PR's own diff before (354fcb32..cc25b9df, 30 files) and after (b5037247..b0bca531, 22 files), and read the new one in full (1,277 lines). - Read in full: 6 reviews, 5 comments, 0 inline comments (from the three files). I also read the current PR body (updated 2026-11-12T11:45:35Z) in full.
- New items since my last review:
- Reviewer 1's round-3 review (2026-11-10T08:08:11Z): approve. Its non-blocking cap note is covered above.
- Integrator comment (2026-11-12T07:13:24Z): asks for a merge of main and a new round. Done: this is the round.
- Integrator comment (2026-11-12T09:07:53Z): the owner approved the behavior change ("975 approve"). The PR body's top block names it, with the old and new behavior and how to turn it off.
- Integrator comment (2026-11-12T11:45:35Z): the port behind
agent/. I checked each point of Port behind the agent interface. See below. - The merge commit: reviewed. Finding 1 comes from it.
- The port, checked against the code:
- Files that left the PR diff (
apply/*,proxy/bobusage.go,bobsession_test.go,bobprofile_test.go,session/*,recctx.go,docs/design.md) were #967's commits. They are now in main. They are not lost. agent.Usage.Backend: a plain label field.readAgentUsagepasses it in and copies it out. A panic in the agent givesbase, whoseBackendis""(fail open).TestReadAgentUsageTakesOnlyTheTokenCountsFromTheAgentnow covers the label too.- Only Bob labels a reply. The only callers of
readAgentUsageareproxy.go:2420(buffered) and:2844(streamRecOn). Both getag := h.agentFor(up.path)fromserve.streamRec(passthrough,/count_tokens) passesagent.Base{}, whoseReadUsagereturnsbase. So no other route moves a Bob counter.TestNonBobRouteRecordsNoBackendchecks this. - Token counts did not change. The old
ReadUsagetookGetBytes(reply, "usage")for JSON and the lastPresentusage chunk for a stream.bobMarksOfreturns the same block: the lastPresentusageof the top-level object or of thedata:chunks. A non-object JSON body gives no block, andreadUsagereturnsbasewhen the block is not an object, so the result is the same. When the shared parser read no usage, the host keeps its own counts and takes onlyBackend(proxy.go:2421-2425,:2845-2849). - The label reaches the row on all 3 paths: the 2 stream paths copy
u.Backendalso whenokis false (proxy.go:2310,:2402). The buffered path copies it at:2422-2424and:2430.capture.finishsetse.Backend(dashcapture.go:697).backendOfallow-lists it ininsertBatch. - Counts once per reply round, as before the port. The expand loop can count one request more than once. The PR names this under Known limits.
- Rule, marks, key and WARN in
agent/bob/usage.goare the same code ascc25b9df'sproxy/bobusage.go, renamed. I compared them line by line.
- Files that left the PR diff (
- CI on
b0bca531:build-testfails (finding 1). CodeQL, DCO,purego,build,trivypass. - I did not run Go builds or tests. Live tests are not approved for this review.
Move the backend-label sentence into the billed-token row file and regenerate docs/data-dependence.md with gen-datadep. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
Fixed in 37443f3.
|
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (claude, user of @amiddavid) | Claude Code 2.1.322 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 5 of 5 | 37443f3f17a9 |
approve |
Verdict: approve
Findings
None.
Earlier findings
- R2 round 4, finding 1 (the generated page was edited by hand): fixed in
37443f3f. Reviewer 1's round-4 finding 1 is the same defect, and the same commit fixes it.- The Bob backend sentences are now in the body of
docs/data-dependence/features/billed-token-and-cache-time-records.md. - The row body appears exactly once, word for word, in
docs/data-dependence.md(grep -cFon the row body gives 1). - Against the new base
981c7eaf, the page diff is 1 line out and 1 line in. That is the same paragraph as the row file change. Nothing else on the page moves.
- The Bob backend sentences are now in the body of
- All earlier findings (R1-1, R2-1, R2 round 2 finding 1, R1 round 2 finding 1): stay fixed. The PR's own code diff is the same as at
b0bca531. I comparedgit diff b5037247..b0bca531withgit diff 981c7eaf..37443f3f. The only difference is the row file and the regenerated page. - Round-4 non-blocking notes (mine and reviewer 1's): not changed. The
ReadUsagedoc still does not say thatBob.ReadUsagemoves counters and that the host calls it once per reply. The twoif okblocks inproxy/proxy.go:2421-2431are still there. The behavior is correct, so neither blocks. - Round-3 non-blocking notes (
bobShapeMax = 8, the "22- and 24-character ids" line in the PR body,id_no_usageand helpers): not changed. They are still small.
Non-blocking
- CI
build-testandrecordwere still running on37443f3fwhen I posted. The fix is a docs change only. Check thatbuild-testis green before merge.
What I checked
- Last review: round 4,
b0bca531d3b625efed45d29a1dd74c27f731269f, 2026-11-12T12:11:04Z - New commits read: 1 on the PR side,
37443f3f"Merge origin/main into feat/bob-backend-label". It brings in 5 commits of main (4a7f8d7e#1122,09f96c53#1125,1bed2683#1113,abb77b19#1120,981c7eaf#1119). I did not review main's own commits. The merge's own change: the row file and the regenerated page. - Read in full: 8 reviews, 6 comments, 0 inline comments (from the three files).
- New items since my last review:
- Reviewer 1's round-4 review (2026-11-12T12:10:42Z): blocking, on the same generated-page defect as mine. It is fixed. Its non-blocking notes are the same as mine and are not changed.
- The author's reply (2026-11-12T12:37:45Z): says the sentence moved to the row file, the page comes from
gen-datadep, the only merge conflict was the generated page, and tests passed on the box. I checked the first 3 claims against the diff, and they hold. I cannot check the test run on the box from here. CI is still running. - Commit
37443f3f: reviewed. Its message names the fix and has the DCO sign-off andAssisted-By.
- Read the full PR diff against the new base,
git diff 981c7eaf..HEAD(23 files, +869/−39), and compared it line by line with the round-4 diff. - CI on
37443f3f: CodeQL, DCO,purego,build,trivyandanalyzepass.build-testandrecordare in progress. - I did not run Go builds or tests. Live tests are not approved for this review.
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (claude, user of @amiddavid) | Claude Code 2.1.322 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 5 of 5 | 37443f3f17a9 |
approve |
Verdict: approve
Findings
None.
Earlier findings
- R1 round 4, finding 1, and R2 round 4, finding 1 (the generated page was edited by hand, and CI failed): fixed in
37443f3f.- The row file
docs/data-dependence/features/billed-token-and-cache-time-records.mdnow has the backend-label sentences. - The row's text in
docs/data-dependence.md:228is now exactly the row file's body. I checked this with a fixed-string grep of the body inside the table row: 1 match. - Against main (
981c7eaf), the page diff is that one line only. Main's new text for the "Session state table" row (#1104, hosted) is kept in full. - No conflict markers remain in any changed file.
- The row file
- Earlier rounds (R1-1, R2-1, R2 round 2 finding 1, R1 round 2 finding 1): stay fixed. The code is the same as at
b0bca531. See below. - Non-blocking notes from round 4 (mine and reviewer 2's): the
ReadUsageside-effect doc line and the doubleif okare not changed. Both are still non-blocking. The round-3 notes (the "22- and 24-character ids" line in the PR body,bobShapeMax = 8,id_no_usagecounting a helper with no usage) are also unchanged and non-blocking.
Non-blocking
- CI
build-testandrecordwere still running at37443f3fwhen I posted this review. Check thatbuild-testis green before merge. The author reports that the drift test,go vetand-raceon./agent/...and./proxy/...pass on the box.
What I checked
- Last review: round 4,
b0bca531d3b625efed45d29a1dd74c27f731269f, 2026-11-12T12:10:42Z - New commits read: 1 on the PR side:
37443f3fMerge origin/main into feat/bob-backend-label.git log b0bca531..HEAD ^981c7eafgives only this commit. The other new commits are main's own: #1119, #1120, #1113, #1125 and #1122. I did not review those. - Read in full: 8 reviews, 6 comments, 0 inline comments (from the three files)
- New items since my last review:
- My own round-4 review (2026-11-12T12:10:42Z): its finding is fixed. See above.
- Reviewer 2's round-4 review (2026-11-12T12:11:04Z, at
b0bca531): its finding 1 is the same as my round-4 finding, and it is fixed. I checked its non-blocking notes. They match mine and stay non-blocking. - The author's comment "Fixed in 37443f3" (2026-11-12T12:37:45Z): I checked each point against the commit. The row file is updated. The page matches the generator's form (the row is the row file's body). The only conflict was the generated page. I cannot check the box test runs from the code. CI is still running.
- The merge content: I compared
37443f3fwith git's automatic merge of its 2 parents (git merge-tree --write-tree b0bca531 981c7eaf). Only 2 files differ: the conflict indocs/data-dependence.md, resolved as above, and the row file. No code file differs from the automatic merge. - The PR's code diff is unchanged:
git diff b5037247..b0bca531andgit diff 981c7eaf..HEAD, with the data-dependence files left out, are equal. So my round-4 review of the code still holds: 22 code and test files, 1 row file. - CI at
37443f3f: CodeQL, DCO,build,purego,trivyandanalyzepass.build-testandrecordare in progress. - I did not run Go builds or tests (not approved, Go not installed).
main changed the Bob plugin data-dependence row (#975, #1111). The row takes main's text, plus this PR's sentence on the status bar's money and unit. The page is rebuilt with gen-datadep. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Vitaly Zabershinsky <[email protected]>
Summary
IBM serves Bob's model route from 2 backends. They count tokens differently, so a comparison between 2 presets is only valid on one backend. Until now the proxy recorded no backend. On Bob's route only, it now labels each reply with the backend that served it.
What we found
2 captures of real Bob replies. They logged field names and short values only: no prompt, no answer, no full id.
chatcmpl-…, 45 characters-or_usage.prompt_tokens_detailscache_write_tokens: on all 24 A repliesmodelispremium-ideon both.system_fingerprintis empty on both. No response header names the backend.router(no id, no usage) andsecurity(achatcmpl-id and no cache fields).The rule
Achatcmpl-, and the usage hascache_write_tokensBchatcmpl-, and the usage has nocache_write_tokensand nocache_creation_token_details. The id's length and characters are not checked""(none)securityorrouter)otherchatcmpl-id with no cache writes, a non-chatcmpl-id with cache writes, or mixed ids in one streamotheris the alarm. It means the 2 marks disagree, so a reply is never put inAorBon one mark alone.cg.bob_backend_unknownonce per kind of shape. The kind is thechatcmpl-start and the 3 usage marks; the id's own letters are not part of it.alnum,cache_write,creation_details,mixed_ids,provider_fields.2 policy choices:
other. It should never happen: a reply that changed server mid-stream would lose its cache.""and no alarm. It is also counted apart, inid_no_usage, to collect data before anyone decides how to label it.Replayed on all 158 real requests: no
AorBlabel moves; 14 B replies that the first, stricter rule calledotherare nowB; 18 helper replies get""; 0 areother.What changed
proxy/bobusage.go: the rule (bobBackend), one reading pass over the reply (bobMarksOf), the counters and the alarm.proxy/proxy.go: the label is read on all 3 reply paths (streamed, buffered, splice), also when the reply has no usage. Only Bob's route reads it.backend, added by the existing additive migration. Old rows read"". OnlyA,Bandotherare stored; any other value is stored as""./stats:bob_backend: {A, B, other, none, id_no_usage}, counts only./api/requests: rows havebackend, left out when empty.docs/data-dependence.mdanddocs/reference/reference.md.Data dependence
Metadata only. The proxy reads the reply id's shape and the names of the usage fields, and keeps a label of at most 5 letters. It never stores or logs the id.
/statsstill countsHow it was tested
AandBare swapped.AandBrows get the right label;otherreply logs one WARN over 2 replies, and the counter goes up by 2;"", with no WARN;id_no_usage.Aat all 167 possible cut offsets. A careless reader that takes a cut id fails this test (otherat 44 offsets)."".A,B, and""for the router call.go test ./proxy/ ./dash/ ./metrics/ ./components/all/: OK.go vetandgofmt: clean./statsgolden test and the Prometheus coverage test only gained the new field.bob_backendis/statsonly for now, and is not exported to Prometheus yet.Known limits
chatcmpl-and that sends no cache-write fields is labelledB. Before8a22c9ae, a different id length raisedother. The rule no longer checks length, because real B ids vary. So a preset comparison "on B only" could mix 2 backends without a warning. WatchB's token counts: 2 size groups for the same request would mean 2 backends.chatcmpl-is the standard OpenAI id format. A new OpenAI-style backend would likely look likeA. To spot it, watchA's token counts: 2 size groups for the same request would mean 2 backends./stats. The row keeps the last round's label.none.security,router). A new helper model would be labelled by its marks, and could raiseother.Port behind the agent interface (integrator, 2026-11-12)
Main moved Bob logic behind
agent/andagent/bob(#1029). The owner approved this port on 2026-11-12.agent.Usagehas a newBackendfield: a short label the agent sets. It is set with or without usage.agent/bob/usage.go: the marks, the A/B/other rule, the counters and the once-per-shape warning.Bob.ReadUsagesetsBackend.readAgentUsageon every reply. When the shared parser found no usage, the token counts stay as the parser read them. OnlyBackendcomes from the agent./statsstill reportsbob_backend, filled bybob.BackendCounts().bob.ResetBackendForTestis exported, because tests inproxyneed it.agent/bob/backend_test.go. Handler, stats and stream tests stay inproxy/bobbackend_test.go.