Skip to content

feat(proxy): Bob chat sessions and cache-write usage, Bob route only - #967

Merged
amiddavid merged 4 commits into
mainfrom
feat/bob-proxy-route
Nov 9, 2026
Merged

amiddavid merged 4 commits into
mainfrom
feat/bob-proxy-route

Conversation

@vz-ibm

@vz-ibm vz-ibm commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Behavior change, Bob route only (POST /inference/v1/chat/completions, mounted with --bob-upstream or in hosted mode). No other route changes.

  • Who it affects: Bob IDE and Bob Shell users routed through context-guru.
  • Session. Old: every Bob IDE chat got a session id hashed from its first messages. New: a Bob IDE request takes its session from its X-Task-Id header, so each Bob chat is one session. An explicit x-context-guru-session header or a body id still wins.
  • Usage. Old: Bob's cache writes were counted as fresh input, and its 1-hour writes were lost. New: the Bob route reads cache_write_tokens and the 1-hour part. Fresh input = prompt − cache read − cache write.
  • Cost. About 20k tokens per Bob call move from the input price to the cache-write price, so cost_usd on Bob rows changes. The dashboard prices Bob from the price list; it has no Bobcoin price.
  • Restart grace. Bob rows now carry 1-hour writes, so after a proxy restart a Bob thread can get the 1-hour tier (fix(dash): seed the billed cache tier after a restart #958). This can change a cold or warm decision, not only the status bar.
  • To turn it off: there is no narrow switch. On a local proxy, do not set --bob-upstream: that turns off all Bob support, not only this change. A hosted proxy (Tenants set) always mounts the Bob route.
  • Upgrade: a Bob IDE chat open during the upgrade gets a new session id on its next turn. That turn can pay one cache write.

Summary

Two fixes for IBM Bob traffic, on Bob's model route only:

  1. Each Bob IDE chat is now its own session.
  2. The dashboard reads Bob's cache writes, so the cache clock and the fresh-input counts are correct.

What we found

  • Session. The Bob IDE sends its chat id only in the X-Task-Id header. The proxy did not read it. So it hashed the start of each conversation. Two chats that start the same way shared one session.
  • Usage. Bob adds cache-write fields to the OpenAI Chat Completions usage block: prompt_tokens_details.cache_write_tokens and cache_creation_token_details.ephemeral_1h_input_tokens. Standard OpenAI does not send them, so the shared parser ignores them. Example from a real Bob call: 20,315 cache-write tokens were counted as fresh input (20,319 shown, 4 correct), and the 20,157 one-hour tokens were dropped. So /api/cachestate said 5 minutes for a cache that lives 1 hour.

What changed

  • proxy/proxy.go: explicitSessionOf gives one session id to the pipeline, the expand repair, the observe record and the wire recorder. Only the Bob model route reads X-Task-Id.
    • Why only that route: the header has no vendor prefix, so any client could send it.
  • session/session.go: Explicit takes host ids, tried last.
    • So x-context-guru-session and body ids still win over them.
  • proxy/bobusage.go (new): bobUsage reads Bob's cache writes. It is called only on the Bob route. providerusage.Parse is unchanged.
    • Fail open: a field that is missing or of the wrong type leaves the shared parser's value.
  • proxy/recctx.go, proxy/dashcapture.go, apply/: pass the one session id through.
  • Tests:
    • proxy/bobsession_test.go and proxy/bobusage_test.go: the new code, with real Bob usage blocks.
    • proxy/bobsession_test.go TestBobExpandRepairKeysItsMarkByTheXTaskIDSession: the expand repair marks the restored content under the Bob session. It fails with the raw header id (review round 1).
    • proxy/bobprofile_test.go: pins the existing region strip.
    • proxy/dash_test.go: the bob agent label.
    • Others prove that the other routes do not change.

Data dependence

Metadata only: a header value (a task id) and token counts. No content is read or stored.

Storage level What it does
Off Works. The session id lives only for the request.
Metadata only Works. The task id becomes the session id, a label.
Everything Same as metadata.

docs/data-dependence.md: the "Session tracker" and "Billed-token and cache-time records" rows now say what Bob sends. This PR does not change any feature's data dependence.

How it was tested

  • make lint: exit 0. go build ./...: OK.
  • go test ./session/ ./apply/ ./dash/: OK.
  • go test ./proxy/: all pass except TestALateFirstByteOnTheRealTransportNeverReachesTheClient. That is the known flaky test test: TestALateFirstByteOnTheRealTransportNeverReachesTheClient is flaky under -race #847: with -count=10 it fails 6 of 10 on clean main and 5 of 10 on this branch.
  • Live, on a real Bob IDE (2026-11-08 and 11-09):
    • Each chat got its own session from X-Task-Id.
    • A call showed fresh 4, cache_write 20,774, cache_write_1h 20,616. The status bar showed the 1-hour cache clock.

Technical notes

  • explicitSessionOf runs once in chat. The expand repair uses that value. serve calls it again on the observe path, on the post-pipeline body. The id is the same, because no component changes metadata.
  • streamRecOn(…, bob) is streamRec with the Bob usage reader on. streamRec calls it with false, so other callers do not change.

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]>

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 0f30a559a681 approve

Verdict: approve

Findings

None. I found no wrong behavior, no broken fail-open path and no missing test for the new behavior.

Non-blocking

  • docs/design.md:286-292 ("Session keying") is now incomplete. It lists the explicit id sources: the header, then user_id and taskId. It does not say that the Bob model route also reads X-Task-Id, last. session/session.go and docs/data-dependence.md say it. The design doc does not. Add one clause there.
  • The PR body's technical notes have one wrong line. It says "serve calls it again only on the expand path". In the code, serve calls explicitSessionOf again on the observe path (proxy/proxy.go:1989). The expand repair uses the explicitSess value from chat (proxy/proxy.go:1402). The code is correct. Only the text is wrong.
  • The expand repair has no Bob-specific test. proxy/proxy.go:1402 now passes explicitSess to EnforcedSessionIDFor. No test sends a Bob IDE request with a dangling expand error and checks the repair's session key. The change is one argument, and the pipeline test covers the same id. A small test would stop a later edit from passing the raw header again.
  • bobResponseUsage scans an SSE body a second time (proxy/bobusage.go:237). string(body) copies the window, and the loop parses each data: line again. It runs on the Bob route only, and the sniffer window is bounded, so the cost is small.
  • One-time session move on upgrade. A Bob IDE chat that is open during the upgrade gets a new session id (the X-Task-Id) on its next turn. Its cached-prefix boundary and frozen decisions are keyed on the old content-hash id, so that turn can pay one cache write. The grace alias is still the content hash (graceAliasID passes ""), so the restart grace still finds the old id. The PR top names the behavior change. I cannot see if a human developer has said yes to it. That yes is needed before merge (CLAUDE.md, RELEASING.md).

What I checked

  • I read every changed line in all 3 commits and all 17 files, including the 4 new test files.
  • Session precedence. session.explicit puts host ids after the header and the metadata fields (session/session.go:159). ExplicitStrict passes nil, so the bifrost adapter does not change. Every host id goes through ExplicitID, so safeExplicit rejects an unsafe, empty or too-long X-Task-Id, and Scoped then falls back to the content hash (fail open).
  • Route gate. explicitSessionOf reads X-Task-Id only when upPath == bobModelPath. chat passes static.path, and serve passes up.path. upstreamFor copies the path verbatim, so the two agree. On other routes the function returns the raw header, as before.
  • Every place that derives the chat session. I searched for x-context-guru-session, SessionIDFor, EnforcedSessionIDFor, ExplicitSession and session.Scoped. The pipeline (modes.go r.session), the expand repair, the observe-mode billed-input record and the wire recorder all use the one id. /compact (proxy.go:909) and /expand (proxy.go:3011) still read the header only. Neither is the Bob model route, so that is correct.
  • Resolved id passed back as Opts.Session. On the Bob route, o.Session is now the resolved id. sessionIDFrom gets the same id back, because the header wins. BodyOpts:505 still sees an explicit id, so alias stays the content hash. A Claude Code JSON user_id is unwrapped to its session_id first, and that resolves to the same id again.
  • Hosted mode. Scoped adds the tenant prefix to the X-Task-Id. One tenant cannot name another tenant's session.
  • bobUsage arithmetic. I traced the two real blocks. Cold block: prompt 20,319, read 0, write 20,315, 1h 20,157, so fresh = 4. Warm block: prompt 20,418, read 20,315, write 99, so fresh = 4. These match the test values. Each bad input returns base: not an object, no integer prompt_tokens, a write field that is negative, fractional or a string, 1h > write, or read + write > prompt.
  • Where bobUsage runs. It runs on the buffered path (proxy.go:2305) and on both stream paths through streamRecOn (proxy.go:2181, 2279), only when bob is true and the shared parser returned ok. streamRec and stream pass false, so other callers do not change. providerusage.Parse does not change, and TestSharedParserStillIgnoresBobWrites pins it.
  • Effect downstream. Keep-alive pings never run for provider == OpenAI (proxy/keepalive.go:377, 428). So the new 1h tier changes the dashboard row, the cost and /api/cachestate, and not the ping schedule. Billed input (fresh + read + write) stays the same sum, because Bob's prompt_tokens already includes the writes.
  • Data dependence. The PR uses only a header value and token counts. The two docs/data-dependence.md rows say this, and no feature's level changes.
  • Tests (read only, not run). The tests cover: X-Task-Id as the session, split and join by task id, body taskId and user_id and the session header winning, unsafe ids falling back, other routes ignoring the header, observe mode recording under the task id, wire files keyed on the task id, Bob usage on JSON, SSE and the buffered tool path, other routes reading the same block as before, and the agent label. Go is not installed here, and live tests are not approved, so I did not run them.

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 0f30a559a681 approve

Verdict: approve

Findings

None. I found no wrong behavior, no broken fail-open path, and no missing test for the new behavior.

Non-blocking

  • PR body, "To turn it off". The Bob route is also mounted when Tenants != nil (proxy/proxy.go:614). So a hosted proxy cannot turn the change off. On a local proxy, "do not set --bob-upstream" also turns off all Bob support, not only this change. The human who approves the behavior change should know that there is no narrow off switch.
  • The cost of Bob rows changes too. The PR body names the fresh-input and 1-hour changes. It does not say that cost_usd on Bob rows also changes: about 20k tokens move from the input price to the cache-write price (and the 1-hour premium, modelinfo.Price.CostWithCacheWrite1h). This is the correct result, but it is one more user-visible number that moves. Add one line to the behavior-change block.
  • The dashboard tier now feeds the restart grace for Bob. With CacheWrite1h now on Bob rows, billedTierSQL (dash/cachestate.go:255) can give a 1-hour tier to a Bob thread after a restart (#958). That can change a cold/warm decision in the pipeline, not only the status bar. It is in the spirit of the PR. A sentence in the PR body would make it visible to the approver.
  • bobResponseUsage on a spliced sniffer window (proxy/bobusage.go:236-246). It scans win line by line. On a spliced window a truncated data: line can hold a partial object. usagePresent and bobCount reject most bad shapes, and the result falls back to base, so this fails open. No test covers a spliced window with the usage chunk in the tail. Low risk.
  • Two derivations of the explicit id per expand request. serve calls explicitSessionOf again at proxy/proxy.go:1989 on the post-pipeline body, not the pre-pipeline one. The id is the same as long as no component changes metadata. No component does that today. Passing explicitSess into serve would remove the doubt, but it is not a defect now.

What I checked

  • Every changed line in all 17 files of 354fcb32..0f30a559 (3 commits), and the PR body.
  • Session path. explicitSessionOf (proxy/proxy.go:712) reads X-Task-Id only when upPath == bobModelPath. All four chat-path consumers get the same id: BodyOpts via modes.go:58 (session: explicitSess), the expand repair (:1402), the observe billed-input record (:1989), and the wire recorder (newRecCtx, recctx.go:109). /compact (:909) and /expand (:3011) still read only x-context-guru-session. Those routes are not Bob routes, so that is correct.
  • Precedence. session.explicit appends host ids after the header and the metadata fields (session/session.go:159). ExplicitStrict passes nil, so the bifrost adapter does not change. safeExplicit still guards the host id. The unit test TestExplicitHostIDsComeLast and the proxy tests cover header, user_id, taskId, unsafe, long and empty values.
  • Alias ids. BodyOpts:505 gets a non-empty explicit id for a Bob IDE call, so its alias is the content hash. graceAliasID and the dashboard AliasFn (dashcapture.go:659) both pass "", so they also derive the content hash. The three agree. The new comments say this correctly.
  • Tenant isolation. session.Scoped prefixes the tenant, so a client-set X-Task-Id cannot reach another tenant's state. Inside one tenant, a client could already set x-context-guru-session, so X-Task-Id adds no new power.
  • Usage path. responseUsageWhy has only two call sites (proxy/proxy.go:2305 buffered, :2702 sniffed stream). Both apply bobResponseUsage only when bob is true. streamRec passes false, so h.stream callers (counttokens.go:109, proxy.go:693) do not change. providerusage.Parse does not change, and TestSharedParserStillIgnoresBobWrites pins that.
  • bobUsage arithmetic. Cold block: 20319 − 0 − 20315 = 4 fresh, 1h 20157 ≤ 20315. Warm block: 20418 − 20315 − 99 = 4. The guards (write1h > write, read + write > prompt, non-integer, negative, string) all return base. That is fail open.
  • Keep-alive. Pings use keepalive.PingUsage (shared parser), not bobUsage. canPing refuses OpenAI providers, and the Bob route is bschemas.OpenAI, so no Bob ping exists to misread. ResolveTier needs AllBreakpointsAskExtendedTTL(body), which an OpenAI body does not meet, so the keeper schedule does not change.
  • Tests. JSON, SSE and buffered (expand tool) paths write the corrected row and /api/cachestate shows ttl_s 3600. The /openai and /anthropic routes keep today's numbers for the same block. X-Task-Id is ignored on non-Bob routes. Observe mode records cg:bin: under the task id. The wire file is keyed on the task id end to end.
  • Data dependence. docs/data-dependence.md updates the "Session tracker" and "Billed-token" rows. Both stay metadata only. The PR states that it does not change any feature's data dependence. I agree.
  • I did not run Go builds or tests. Live tests are not approved, and Go is not installed here.

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]>
@vz-ibm

vz-ibm commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator Author

Round 1: replies

Both reviews approve with no blocking findings. I acted on the non-blocking notes in 899ea9d1 and in the PR body.

R1: no narrow off switch. Correct. The behavior-change block now says so: on a local proxy, leaving out --bob-upstream turns off all Bob support, and a hosted proxy always mounts the route. The first line no longer says "mounted only with --bob-upstream".

R1: cost_usd on Bob rows changes. Added to the block.

R1: the 1-hour tier can feed the restart grace (#958). Added to the block.

R1: bobResponseUsage on a spliced sniffer window. No change. As you say, a partial object fails usagePresent or bobCount, and the result falls back to base. It fails open.

R1: two derivations of the explicit id. No change now. No component changes metadata, so the ids are the same. The technical note now says this.

R2: docs/design.md "Session keying" is incomplete. Fixed in 899ea9d1: it lists X-Task-Id, on Bob's model route only, last.

R2: wrong line in the technical notes. Fixed: serve calls explicitSessionOf again on the observe path. The expand repair uses the value from chat.

R2: no Bob-specific test for the expand repair. Added TestBobExpandRepairKeysItsMarkByTheXTaskIDSession in 899ea9d1.

  • A Bob IDE request with X-Task-Id runs the repair twice.
  • Turn 2 must carry the restored content whole.
  • I checked that it fails when the repair uses the raw x-context-guru-session header: the pipeline then compacts the content back (tokens_after=34 from 2,201).

R2: bobResponseUsage scans the window again. No change. It is on the Bob route only, and the window is bounded.

R2: one-time session move on upgrade. Added to the block ("Upgrade").

Human yes. The behavior change is named at the top. It needs a human developer's yes before merge.

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 899ea9d1f17b approve

Verdict: approve

Findings

None. The new commit adds one test and one doc clause. Both are correct.

Earlier notes: status

Neither reviewer had a blocking finding in round 1. All notes were non-blocking.

Reviewer 1 (mine):

  1. No narrow off switch. Fixed in the PR body. The block now says that a hosted proxy always mounts the route and that a local proxy has no switch narrower than --bob-upstream.
  2. cost_usd on Bob rows changes. Fixed in the PR body ("Cost").
  3. The 1-hour tier can feed the restart grace. Fixed in the PR body ("Restart grace").
  4. Spliced sniffer window. Rejected by the author: it fails open. I accept this. A partial object fails usagePresent or bobCount, and bobUsage returns base.
  5. Two derivations of the explicit id. Rejected for now by the author: no component changes metadata. I accept this. The technical note says it.

Reviewer 2:

  1. docs/design.md "Session keying" is incomplete. Fixed in 899ea9d1. The clause names X-Task-Id, on Bob's model route only, last. That matches session.explicit (session/session.go:159).
  2. Wrong line in the technical notes. Fixed in the PR body. It now says that serve calls explicitSessionOf again on the observe path.
  3. No Bob test for the expand repair. Fixed in 899ea9d1. See "What I checked".
  4. bobResponseUsage scans the window again. Rejected by the author: Bob route only, bounded window. I accept this.
  5. Session move on upgrade. Fixed in the PR body ("Upgrade").

Non-blocking

  • A human's yes is still needed before merge. The PR names a behavior change at the top. CLAUDE.md and RELEASING.md need a human developer to approve it. I see no such approval in the conversation yet. The author's reply says the same.
  • forwarded in the new test (proxy/bobsession_test.go:243-246). The upstream handler appends from its own goroutine, and the test reads it after the calls. make test runs with -race. The race detector does not see a happens-before link across the TCP round trip. proxy/expand_duplication_test.go:39 and :123 use the same pattern and pass today, so this is low risk. A mutex would remove the doubt.

What I checked

  • Last review: round 1, 0f30a559a68187b2e318966184617895798cf675, 2026-11-09T07:26:54Z
  • New commits read: 1 — 899ea9d1 test(proxy): pin the Bob expand repair to the X-Task-Id session
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
  • New items since my last review:
    • Commit 899ea9d1. I read the whole diff (docs/design.md, proxy/bobsession_test.go) and the code it tests.
    • Author comment at 2026-11-09T07:34:45Z ("Round 1: replies"). I checked each reply against the code and the new PR body. The status of each note is above.
    • The PR body (edited). I read the new behavior-change block. It names who it affects, old and new behavior, cost, restart grace, the off switch and the upgrade effect.
    • Reviewer 2's round-1 review (07:26:49Z) is older than my review, but I read it now for the first time, as round 1 required. It has no blocking findings.
  • The new test. TestBobExpandRepairKeysItsMarkByTheXTaskIDSession sends a Bob IDE request with X-Task-Id and a dangling context_guru_expand error, two times. repairExpandErrors (proxy/proxy.go:1760) restores the stashed original and calls MarkKeptVerbatim under sessionOf(out). That is EnforcedSessionIDFor(..., explicitSess, ...) at :1402, so the key is the X-Task-Id session. The pipeline reads the mark under the same id, so turn 2 carries all 200 copies of the probe line. With the raw header id, the mark goes to the content-hash session and the pipeline compacts the content again. The author reports that the test fails that way (tokens_after=34 from 2,201). The test can fail for the intended reason.
  • Test setup. dashHandler builds the handler without BobUpstream. The test sets h.opts.BobUpstream before it calls h.Mux(), and Mux reads the option at call time (proxy/proxy.go:614-616). So the Bob route is mounted and its upstream is the fake server.
  • Doc clause. docs/design.md:289-291 now matches session/session.go and docs/data-dependence.md.
  • I did not run Go builds or tests. Live tests are not approved, and Go is not installed here.

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 899ea9d1f17b approve

Verdict: approve

Findings

None. The new commit adds one test and one doc clause. Both are correct.

Earlier findings

Neither reviewer had a blocking finding in round 1. Status of the non-blocking notes:

Mine (reviewer 2):

  • docs/design.md "Session keying" was incomplete. Fixed in 899ea9d1. The text now says: after the metadata ids, on Bob's model route only, the X-Task-Id header (explicitSessionOf). This matches session.explicit and explicitSessionOf.
  • Wrong line in the PR body's technical notes. Fixed in the PR body, as the author's reply says.
  • No Bob-specific test for the expand repair. Fixed: TestBobExpandRepairKeysItsMarkByTheXTaskIDSession. See "What I checked".
  • bobResponseUsage scans the SSE window a second time. Rejected with a reason: it is on the Bob route only and the window is bounded. I accept this. It was only a cost note.
  • One-time session move on upgrade. Fixed: the author added it to the behavior-change block.

Reviewer 1:

  • No narrow off switch, the cost_usd change, and the 1-hour tier feeding the restart grace (#958). Fixed in the PR body's behavior-change block, as the author's reply says.
  • bobResponseUsage on a spliced window. Rejected: it fails open. I agree. A partial object fails usagePresent or bobCount, and bobUsage then returns base (proxy/bobusage.go:185-205).
  • Two derivations of the explicit id. Rejected for now: no component changes metadata, so both calls give the same id. I agree. That holds today, and the technical note now says it.

Non-blocking

  • The new test checks only turn 2 (proxy/bobsession_test.go:275). The older test TestTheRepairPathSendsRecoveredContentUpstreamOnce checks every turn. Turn 2 is the turn that proves the mark key, so this is enough for the claim. I did not run the test. So I cannot confirm the author's report that it fails when the repair uses the raw header (tokens_after=34). The trace below agrees with that report.
  • The human yes is still open. The PR names the behavior change at the top. I see no comment from a human developer that approves it. CLAUDE.md and RELEASING.md need that yes before merge.

What I checked

  • Last review: round 1, 0f30a559a68187b2e318966184617895798cf675, 2026-11-09T07:26:49Z
  • New commits read: 1. 899ea9d1 test(proxy): pin the Bob expand repair to the X-Task-Id session (docs/design.md +2/−1, proxy/bobsession_test.go +47).
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files).
  • New items since my last review:
    • Reviewer 1's round-1 review (07:26:54Z). I checked each of its 5 notes against the code and the author's reply. See "Earlier findings".
    • The author's "Round 1: replies" comment (07:34:45Z). I checked each reply. I accept each rejection. I checked each doc and test fix in the diff. I can see the PR body edits only through the author's reply.
    • Commit 899ea9d1. I read the whole diff and the code around it.
  • The new test, traced.
    • It uses dashHandler (preset codesafe), then sets h.opts.BobUpstream before h.Mux(). Mux reads h.opts.BobUpstream when it runs (proxy/proxy.go:614-622). So the Bob route mounts and its upstream is the fake server.
    • The body holds a context_guru_expand call and the client's "Tool does not exist" answer. HASH is in the store. So repairExpandErrors restores the original on each turn (proxy/proxy.go:1760-1781).
    • The repair marks the original kept-verbatim under sessionOf(out). That is EnforcedSessionIDFor(..., explicitSess, ...), and explicitSess holds the X-Task-Id bob-task-7 (proxy/proxy.go:1402). The pipeline gets the same id through modes.go r.session. So on turn 2 the offloaders see the mark and keep the content whole: 200 probe hits.
    • If the repair used the raw x-context-guru-session header (empty here), the mark goes under the content-hash id. The pipeline uses bob-task-7 and does not see the mark. It compacts the content again, so turn 2 has fewer than 200 hits. So the test can fail for the intended reason.
    • The upstream slice forwarded is written in the handler and read after both requests finish. The same pattern is in proxy/expand_duplication_test.go:36-46.
  • The doc change. It is in the right place in the precedence list. It names the route limit and the function.
  • I did not run Go builds or tests. Live tests are not approved, and Go is not installed here.

@vz-ibm
vz-ibm requested a review from amiddavid November 9, 2026 08:17
@amiddavid
amiddavid merged commit 682f6a9 into main Nov 9, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 9, 2026
amiddavid added a commit that referenced this pull request Nov 12, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants