Repository navigation
feat(agent): an extension point for client agents - #1029
Conversation
Per-agent behavior (IBM Bob today) sits in if-branches on the route inside the shared proxy.go, and each new feature adds one. The agent package is the one extension point: an Agent interface, a neutral Base that gives today's behavior, and a registry by route path. A new agent is one package that embeds Base and overrides only what differs. This adds the package only. No existing file changes, and nothing in the running proxy behaves differently. A test enforces that agent never imports a host package (proxy, proxyapp, cmd). The interface holds what the next step wires: Name, Paths, SessionID and ReadUsage. A method is added when its first caller is; Base keeps that safe for every agent. 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 | 84b883e8d0a4 |
blocking |
Verdict: blocking
The package is small, correct, and has no effect on the running proxy. I found one small defect: the import guard does not cover a host that the package doc names.
Findings
- agent/imports_test.go:52 — the guard misses the bifrost adapter, but the package doc says it enforces the rule for it
- What fails: a later change makes
agentimportgithub.com/rossoctl/context-guru/adapters/bifrost(directly or through another package).TestAgentDoesNotImportAHoststill passes. - Proof:
agent/agent.go:6-7says: "A host (the proxy, the bifrost adapter) imports it; it never imports a host. imports_test.go enforces that."agent/imports_test.go:11says the same: "a host (the proxy, the bifrost adapter) imports it, never the reverse. This test enforces that rule."isHost(line 52) checks only/proxy,/proxyappand/cmd.adapters/bifrostis in the same module (onego.modat the root), sogo list -deps .lists it, butisHostreturns false for it.TestIsHostMatchesEveryHostPackage(line 37) is named "every host package" and also leaves outadapters/.- The PR body is accurate ("fails if
agentimportsproxy,proxyapporcmd/"). The code comments are not.
- Fix: add
"/adapters"to the list inisHost, and addmodule + "/adapters/bifrost"to the true cases inTestIsHostMatchesEveryHostPackage. (Or change both comments to name only proxy, proxyapp and cmd. I prefer the guard fix: the adapter is a host perCLAUDE.md.)
- What fails: a later change makes
Non-blocking
docs/design.mdpackage map has noagent/row.CLAUDE.mdpoints to that table for the layout. Other new packages (tenant/,tooldefer/,kvcache/) are also missing, so this is not new drift. One row ("per-client-agent extension point:Agent,Base, registry by route path") helps the A2 reader.- Fail open for
ReadUsageandSessionIDis a host duty, and only a comment states it.agent.go:23-25says a reply the agent cannot read "must return base unchanged". Nothing recovers a panic in an agent's method. When A2 wires these calls inproxy.go, wrap each call with arecoverthat keepsbase/"", and add a test with a panicking agent. TodaybobResponseUsageis in-tree and trusted, so this is not a defect yet. - Embedding
Basehides a typo in an override. An agent that writesSessionId(notSessionID) still compiles and silently gets"". This is the cost of theBasedesign. A compile check such asvar _ agent.Agent = bob{}does not catch it. A per-agent test that calls each overridden method does. Worth a sentence in the package doc for A2 authors. - Paths match only by exact string. The proxy mux registers
"POST " + bobModelPath, andservecompares the bareup.path. A2 must pass the bare path (no method, no query) toForPath. A doc line onPaths()("exact path, no method prefix") prevents a silent miss that returnsBase. - Error messages with an empty
Name().Registerprints""for an agent with no name, sopath /x is claimed by "" and ""is hard to trace.%Tof the agent would help. Cosmetic. go listin the guard usesexec.LookPath("go").cmd/context-guru-proxy/depguard_test.gousesruntime.GOROOT(). The new choice is better (the comment says why). The old test can move to it later; not in this PR.
What I checked
- Read the full diff (5 new files, 396 lines) and the commit message. No existing file changes.
agent.go: interface,Usage,Base. ComparedUsagewithproxy/usage.go:18-45: the 5 count fields match names and meaning (CacheWrite1his part ofCacheWrite). The proxy-only fields (Searches,Live, …) stay out, which is right for a library type.- Compared the interface with the Bob branches it will replace:
explicitSessionOf/X-Task-Id(proxy/proxy.go:739-747),bobResponseUsage(contentType, body, base)(proxy/bobusage.go:67). TheReadUsagesignature matches.SessionID"tried last" matchesapply.ExplicitSession(sess, body, host...)(apply/apply.go:353), where host ids come after the header and body ids. registry.go:Registerchecks all paths before it writes any, under one lock, so a refused agent claims nothing (test atregistry_test.go:50). Nil agent, empty path, repeated path and a claimed path are refused.ForPathreturnsBase{}for an unclaimed path. PackageRegisterpanics likecomponents.Register(components/registry.go:27).resetDefaultclears the map under the lock and does not swap the variable. It is used only in tests. Noinit()in this package registers anything, so the reset wipes nothing real.- Tests: each assertion checks a specific value. The concurrency tests only prove something under
-race;make testrunsgo test -race. - Library rule:
agentimports onlynet/http,errors,fmt,sync. No host import. - Data dependence: none. The package reads and stores no customer data.
components/all/datadep_test.gocovers registered components only, so no row is needed. - No behavior change: nothing imports
agentyet. - I did not run any build or test (live tests not approved; Go is not installed here).
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 | 84b883e8d0a4 |
blocking |
Verdict: blocking
Findings
- agent/imports_test.go:52 — the import guard does not cover the bifrost adapter, which the package doc names as a host
- What fails:
agent/agent.go:6-7says "A host (the proxy, the bifrost adapter) imports it; it never imports a host. imports_test.go enforces that." ButisHostchecks only/proxy,/proxyappand/cmd. Ifagentimportsgithub.com/rossoctl/context-guru/adapters/bifrost(directly or through another package),TestAgentDoesNotImportAHoststill passes. The rule the doc states is not the rule the test enforces. - Proof:
imports_test.go:52lists[]string{"/proxy", "/proxyapp", "/cmd"}.adapters/is absent.TestIsHostMatchesEveryHostPackage(imports_test.go:37-49) has noadapters/...case, so the gap is not visible in the tests. The PR body also says the test checks onlyproxy,proxyappandcmd/, so the doc comment claims more than the code does. - Fix: add
"/adapters"to the host list and anmodule + "/adapters/bifrost"case toTestIsHostMatchesEveryHostPackage. Or, if the adapter is out of scope on purpose, change the doc comment so it does not claim the test enforces it.
- What fails:
Non-blocking
agent/registry.go:21-24:Registerchecks only an untyped nil. A typed nil pointer ((*myAgent)(nil)) passes the check, anda.Paths()then panics if the method reads a field. In aninit()the result is a panic either way, so the effect is only a less clear message.agent/registry.go:25-37:Registercallsa.Name()while it holds the write lock (in the error paths). An agent whoseNamecallsForPathdeadlocks. This is unlikely; callingPaths()before the lock (as the code does) andName()before the lock too would remove the case.agent/agent.go:24-25:ReadUsagesays "must return base unchanged" on a reply it cannot read, but the library gives no recover. A2 must wrap the call in a recover in the host so that a panic in one agent's parser reverts only that correction (fail open). Worth a line in the A2 plan.docs/design.md"Package map" does not listagent/. The map already misses other packages (tooldefer/,predictive/,kvcache/,tenant/), so this is not new, but A2 is a good time to add the row.agent/registry.go:46:ForPathis an exact string match. A2 must pass the same path form the proxy routes on (no query string, same trailing slash), or a claimed route falls back toBase.
What I checked
- Read the full diff (5 new files, 396 lines) and the commit message. No existing file changes.
CLAUDE.mdrules: the package is a library and imports onlynet/http,errors,fmt,sync. It imports no host. Data dependence: none; no component is registered, socomponents/all/datadep_test.gois not affected.- No behavior change: nothing in the repo imports
agent/yet (grepfor the import path finds only the new package). Basemethods return neutral values; the embed test proves an agent that overrides one method keeps the others neutral.Registry.Registeris all-or-nothing: it checks every path before it writes any.TestRegisterRefusesAPathAnotherAgentClaimsproves a refused agent claims nothing.- Locking:
Registertakes the write lock,ForPaththe read lock;resetDefaultclears the map under the lock and does not swap the package variable. imports_test.gousesexec.LookPath("go"). Since Go 1.19,go testputs$GOROOT/binfirst on the test'sPATH, so this finds the toolchain that runs the test. Thecontains(deps, module+"/agent")check stops a vacuous pass.- Compared
agent.Usagewithproxy.Usage(proxy/usage.go:18): the 5 count fields match by name. The host must keep its non-count fields (Searches,Live, ...) when it maps back; that is A2 work. - I did not run Go tests (not approved, Go is not installed).
The package doc said the guard enforces "a host (the proxy, the bifrost adapter) never" imports agent, but it checked only proxy, proxyapp and cmd. It now checks adapters too; a probe that imports adapters/bifrost fails it. Register calls the agent's Name and Paths before it takes the lock, so an agent method that calls back into the registry cannot deadlock it. Paths() documents the exact match. docs/design.md lists agent/. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Vitaly Zabershinsky <[email protected]>
Round 1: repliesBoth reviewers found the same gap. Fixed in R1-1 and R2-1: the import guard does not cover the bifrost adapter. Correct: the doc said the guard enforces the rule for "the bifrost adapter", but
Non-blocking, fixed:
Non-blocking, for A2 (the wiring step):
Checks
|
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 | bf80677f9c25 |
approve |
Verdict: approve
Findings
None.
Earlier findings:
- R1-1 and R2-1 (the import guard misses the bifrost adapter): fixed.
isHost(agent/imports_test.go:53) now lists/adapters.TestIsHostMatchesEveryHostPackagehasadaptersandadapters/bifrostas true cases andadaptersishas a false case. Theroot+"/"prefix rule keeps the lookalike out. The doc comments atagent/agent.go:6-7andimports_test.go:11now match the code.
Earlier non-blocking points:
Name()under the write lock (R2): fixed.registry.go:25callsPaths()andName()beforer.mu.Lock(). The duplicate-claim error uses%Tfor the old agent, so no agent method runs under the lock.- Empty
Name()in errors (R1): fixed with%T. - Exact path match (R1, R2): fixed in the
Paths()doc (agent.go:16-17). docs/design.mdpackage map (R1, R2): fixed,agent/row added.- Fail open in the host (R1, R2), typed nil (R2), override typo (R1): the author defers them to A2 or leaves them. I accept this: nothing calls the package yet, and a typed nil in an
init()panics either way.
Non-blocking
- No test proves the deadlock fix. A test agent whose
Name()callsreg.ForPathwould fail (hang) on the old code and pass on the new. Small; fine to add in A2. - The A2 wiring must carry the
recoverand its test that the author promised in the round-1 reply.
What I checked
- Last review: round 1, 84b883e, 2026-11-10T09:37:48Z
- New commits read: 1 (
bf80677ffix(agent): the import guard covers the bifrost adapter) - Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
- New items since my last review:
- Author comment "Round 1: replies" (2026-11-10T09:40:48Z): checked each claim against the diff. All claimed fixes are in
bf80677f. Deferred items are accepted above. - Reviewer 1 round-1 review (09:37:39Z, posted before mine, read now): its one finding is the same as mine and is fixed. Its non-blocking points are covered above.
- Author comment "Round 1: replies" (2026-11-10T09:40:48Z): checked each claim against the diff. All claimed fixes are in
- Read the full diff
84b883e8..bf80677f(4 files, +17/-10) and the whole ofagent/registry.goRegisterandagent/imports_test.goaround the changes. Registerstays all-or-nothing: it checks the empty and repeated paths before the lock, then checks claimed paths and writes all of them under one lock. The existing refusal tests still cover each path.- No behavior change: nothing outside
agent/imports the package. Thedocs/design.mdchange is one table row. - I did not run Go tests (live tests not approved, Go is not installed).
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 | bf80677f9c25 |
approve |
Verdict: approve
The one finding (both reviewers) is fixed. The new commit adds no defect.
Findings
None.
Earlier findings
- R1-1 and R2-1 (guard misses the bifrost adapter): fixed.
isHost(agent/imports_test.go:53) now lists/adapters.TestIsHostMatchesEveryHostPackagehasadaptersandadapters/bifrostas true cases andadaptersishas a false case. Theroot+"/"prefix check makesadaptersishreturn false. The package doc (agent/agent.go:6-7) now matches the guard. - R2 non-blocking,
Name()under the write lock: fixed.RegistercallsPaths()andName()beforer.mu.Lock()(agent/registry.go:25). - R1 non-blocking, empty
Name()in errors: fixed. Messages use%q (%T)for the new agent and%Tfor the old one. - R1 and R2 non-blocking, exact path match: fixed.
Paths()doc (agent/agent.go:16-17) says: exact path, no method, no query, same trailing slash. - R1 and R2 non-blocking,
docs/design.mdrow: fixed.docs/design.md:23addsagent/. - R1 and R2 non-blocking, recover in the host: deferred to A2. I accept this. Nothing calls an agent yet, so no fail-open path exists to break.
- R2 non-blocking, typed nil agent: left as is. I accept the reason: in an
init()it panics either way. - R1 non-blocking, typo hidden by
Base: deferred to A2. I accept the plan. Note: thevar _ agent.Agent = bob{}check does not catch a typo. The planned test that calls the override does.
Non-blocking
- None new.
What I checked
- Last review: round 1, 84b883e, 2026-11-10T09:37:39Z
- New commits read: 1 —
bf80677ffix(agent): the import guard covers the bifrost adapter - Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
- New items since my last review:
- Reviewer 2 round-1 review (09:37:48Z). Its finding 1 is the same as mine. I checked each of its non-blocking points against the new commit (see "Earlier findings").
- Author comment "Round 1: replies" (09:40:48Z). I checked each claim against the diff. All claimed code changes are present.
Registerafter the change: it validates empty and repeated paths before the lock. Under the lock it checks every path for a claim, then writes all. A refused agent still claims nothing, soTestRegisterRefusesAPathAnotherAgentClaimsstill holds.Paths()is called once, so the checked list and the written list are the same.adapters/holds onlybifrost/. It is in the root module, sogo list -depslists it.- No existing behavior changes: only
agent/and one doc row change. Nothing importsagentyet. - I did not run any build or test (live tests not approved; Go is not installed here).
The shared proxy.go read the Bob IDE's X-Task-Id header in an if-branch on Bob's route. It now asks the route's agent (agent.Agent.SessionID): agent/bob returns X-Task-Id, and every other route gets the neutral Base. The session code in proxy.go no longer names Bob or X-Task-Id. No behavior change. proxy/bobsession_test.go is unchanged and green. - With no agent id, the request keeps the bare session header, so an agent that does not override SessionID changes nothing on its route. - A panic in an agent gives no id (fail open); the log names the panic's type only, never its message. - agent/bob registers in init() and carries a compile-time check. The import guard now covers agent/bob too. First move of A2. Bob's route setup, profile handling and usage reading are still in proxy.go, for the next moves. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Vitaly Zabershinsky <[email protected]>
The fail-open tests passed even if the host never called the agent, and nothing tested that a panic's message stays out of the log. The test agent now counts its calls and panics with a canary. The test checks that the agent was asked, that the recovery is logged where it reads, and that the canary is not. Logging the message, or never calling the agent, each fails it. Paths() now says it is the upstream path the host forwards to, not the path the client calls. docs/design.md names agent/bob as the owner of the X-Task-Id rule. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Vitaly Zabershinsky <[email protected]>
The shared proxy decided with a bob flag, in 4 places, whether to read Bob's cache-write fields, and held the parser in proxy/bobusage.go. The parser is now Bob.ReadUsage in agent/bob, and the proxy asks the route's agent through one helper, readAgentUsage. The flag and bobusage.go are gone. No behavior change. proxy/bobusage_test.go is byte-identical; its 5 direct-parser tests compile through a test-only shim, and its end-to-end tests are the proof. - readAgentUsage starts from the shared reading and copies back only the 5 token counts, so every other field stays as it was. - A panic in the agent gives the shared reading (fail open); the log names the types only. - The same gates: the buffered path calls the agent only inside its ok block, the streamed path only when ok. agent/bob copies usagePresent (a library cannot import the proxy). A test fails if the copy accepts an empty block after the real one. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Vitaly Zabershinsky <[email protected]>
The proxy and agent/bob each kept a copy of the rule that says a usage block is there (an object with at least one field). A test guarded the copy in one direction only. The rule is now providerusage.Present, and both use it. docs/design.md names the usage reading in the agent/bob row. Both round-1 reviewers of #1052 raised these 2 points. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Vitaly Zabershinsky <[email protected]>
A shared prefix asker for OpenAI Chat Completions, so the sweep can ask on Chat routes (#1030 item 1). chatPrefixAsker has Ask, AskCovered and CoversSpan, the same contract as the Anthropic and Responses askers. Behavior change, 2 parts: 1. On Chat Completions, a preset with extract_llm_sweep (xhigh, ultrahigh, housellm) now declares context_guru_adjudicate (about 945 bytes) on every request, and the cold sweep can ask at the keep-alive ping. Anthropic and Responses already do this. The warm sweep stays off unless a config sets warm: true. 2. cache_aware_summarizer on Chat with model.source: config and no static cheap model now uses the caller's model through the asker, as on Anthropic and Responses. Shipped presets use incoming and are not affected. On IBM Bob the ask fails open for now (wrong path and auth), until #1030 item 4 / #1029. Owner's yes, 2026-11-10, in the integrator session: "approve both". Data dependence: no change. Reviews: 2 offload reviews (GLM, --no-fallback), round 2, both approve at 93342d9. After it: 3 merges of main with no hand resolution (remerge-diff 0 each), each tested on the merged tree (cheapmodel, components, keepalive, proxy). Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 3 of 3 | 3ee169eff49a |
approve |
Verdict: approve
Findings
None.
Earlier findings
- R1/R2 round 1 (the import guard misses the bifrost adapter): still fixed. After the new commits I re-read
agent/imports_test.goandagent/registry.go.isHoststill refuses/adapters;Registerstill callsPaths()andName()before the lock. The guard now readsgo list -deps ./..., so it coversagent/bobtoo, and it still proves it listed both packages before it checks anything.
Non-blocking
- The round-2 note "a test agent whose
Name()callsreg.ForPathwould pin the deadlock fix" was not added. The fix itself is in the code and I verified it by reading (agent/registry.go:23-25). Fine to leave. agentSessionHandler(proxy/agentsession_test.go) is a copy ofbobSessionHandlerplus the registry override. Small test duplication; the override is the point of the copy.readAgentUsagenow runs, with a deferred recover, on every response, also on routes no agent owns (the neutral agent). One defer per response; negligible.
What I checked
- Last review: round 2, bf80677, 2026-11-10T09:41:50Z
- New commits read: 5 on the branch (
21ebb929refactor(agent): move Bob's session id into agent/bob;4519eeeatest(agent): the agent is asked, and its panic text is not logged;98d50cd8refactor(agent): move Bob's usage reading into agent/bob;562bb9fcrefactor(usage): share the usage-present rule in providerusage;3ee169efmerge of origin/main). The commits the merge brought in are main's own, each reviewed in its own PR; I checked the merge itself. - Read in full: 4 reviews, 1 comment, 0 inline comments (from the three files)
- New items since my last review: none in the conversation. The newest item is reviewer 1's round 2 (09:41:56Z, 6 s after mine); it raises nothing new. So the new material is the 5 commits above.
- Read the full diff
bf80677f..562bb9fc(15 files, +677/-75) and each changed file around the changes:agent/agent.go,agent/bob/{bob,usage}.go,agent/imports_test.go,internal/providerusage,proxy/{proxy,agentusage,usage}.go,proxy/agentsession_test.go,proxy/agentusage_test.go,proxy/bobusage_shim_test.go,docs/design.md. - The merge
3ee169efhas no hand resolution.git merge-tree --write-tree 562bb9fc a067848bexits clean and returns tree4d635c2c, which equals the merge commit's tree. So the merge cannot have changed either side by hand. - Session behavior is unchanged. Old: Bob's route alone read
X-Task-Id, other routes returned the session header. New:agent.ForPathreturns Bob only onbob.ModelPath(the proxy importsagent/bob, so itsinit()registers it),Bob.SessionIDreads the same header, and every other route gets the neutralBase, whoseSessionIDis""→ the session header. Same inputs, same ids. - The empty-agent-id branch keeps the body ids. When no agent id is present,
explicitSessionOfnow returns the bare header instead ofapply.ExplicitSession(sess, body, ""). The pipeline re-reads the body ids downstream (sessionIDFrom→session.Scoped→ExplicitSession), andnewRecCtxre-reads them throughapply.SessionIDFor, so the final session and the wire-record trace id are the same.TestBobShellTaskIDWithoutTheHeaderIsStillTheSessionandTestBobModelCallTakesSessionFromXTaskIDpin both. - The usage move is field-equivalent.
readAgentUsagecopies back only the 5 token counts; Bob's parser (agent/bob/usage.go) changes onlyFreshInput,CacheWriteandCacheWrite1h, and passesCacheReadandOutputthroughbase. The oldbobResponseUsagereturned the same fields off the samebase. The stream-chunk rule is the same function (providerusage.Present), now shared instead of copied. - The A2 promises from round 1 are kept. The host wraps
SessionIDandReadUsagein a recover that reverts only that correction, and logs the panic's type, never its message.TestPanickingAgentSessionIDFailsOpenToTheSessionWithoutTheAgentandTestPanickingAgentReadUsageFailsOpenToTheSharedReadingprove the agent was asked (call counters), that the request still returns 200 with the no-agent result, and that a canary in the panic text stays out of the log.bob_test.gocalls each override, so a typo in one cannot fall through toBasein silence. - No nil
agentForoutsideNew. Production buildsHandleronly inNew(proxy/proxy.go:444), which setsagentFor: agent.ForPath. The many&Handler{}test constructions call methods that never reachagentFor(newRecCtx,compactionPointFor,threadFor, and the like); the end-to-end tests useNew. - Library rules:
agent/bobimports onlyagent,internal/providerusageandgjson— no host. The import guard covers it. Data dependence: none; the parser reads the same usage metadata as before, only from a library package. No behavior change without permission: the commits claim none, and the traces above agree. - I did not run Go tests (live tests not approved; Go is not installed).
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 3 of 3 | 3ee169eff49a |
approve |
Verdict: approve
The PR grew from the A1 package to the first two A2 moves. I checked each move against the old
code path it replaces. I found no defect.
Findings
None.
Earlier findings
- R1-1 and R2-1 (guard missed the bifrost adapter): still fixed.
isHost
(agent/imports_test.go:53) lists/proxy,/proxyapp,/cmd,/adapters. The new commits
kept it, and the guard now also provesagent/bobis listed (imports_test.go:26). - R2 non-blocking,
Name()under the write lock: still fixed.RegistercallsPaths()and
Name()beforer.mu.Lock()(agent/registry.go:55). - R1 and R2 non-blocking, recover in the host: delivered in this round, as promised.
agentSessionID(proxy/proxy.go:760) andreadAgentUsage(proxy/agentusage.go:16) each
recover a panic and fail open. Tests prove the agent was asked (a call counter) and that the
panic's message stays out of the log (a canary). Both call sites are covered: the streamed path
(streamRecOn, plain body) and the buffered path (a tools body gets the expand tool). - R1 non-blocking, override typo hidden by
Base: delivered.var _ agent.Agent = Bob{}
plus a test per overridden method:Name,Paths,SessionID(agent/bob/bob_test.go),
ReadUsage(agent/bob/usage_test.go). - R2 non-blocking, typed nil agent: left as is, as accepted in round 2.
Non-blocking
Agent.Name()has no host caller yet.Base's doc (agent/agent.go:51-52) says the
interface holds "only what a host wires today". The dashboard still labels Bob from its own
strings (dash/event.go,proxy/compactioncfg.go), not fromName(). One doc sentence, or
the A2 wiring, settles it.- Reviewer 2's round-2 note stands: no test proves the
Registerdeadlock fix (an agent whose
Name()callsForPath). Accepted then; still fine.
What I checked
- Last review: round 2, bf80677, 2026-11-10T09:41:56Z
- New commits read: 5 —
21ebb929(Bob's session id into agent/bob),4519eeea(the agent is
asked; the panic text is not logged),98d50cd8(Bob's usage reading into agent/bob),
562bb9fc(share the usage-present rule in providerusage),3ee169ef(merge of origin/main). - Read in full: 4 reviews, 1 comment, 0 inline comments (from the three files).
- New items since my last review: the 5 commits above. No new comment or review arrived after
2026-11-10T09:41:56Z; reviewer 2's round-2 review (09:41:50Z) I read now in full — its two
notes are answered above. - Read the full PR diff against the base (
a067848b..3ee169ef, 18 files, +1071/−66) and each
changed file around the changes. - Session move, no behavior change. Old code on Bob's route always called
apply.ExplicitSession(sess, body, X-Task-Id). New code returns baresesswhen the agent id
is empty. I traced every consumer ofexplicitSessionOf:apply.BodyOpts→sessionIDFrom
(apply/apply.go:1473),EnforcedSessionIDFor→SessionIDFor(apply/apply.go:1504), and
newRecCtx→SessionIDFor. Each re-reads the body ids throughExplicitSession, in the same
order (header,user_id,taskId, agent id). The results converge in every case I traced:
header set, body id set, both, neither.TestBobShellTaskIDWithoutTheHeaderIsStillTheSession
pins the one case that could differ. - Usage move, no behavior change.
agent/bob/usage.goholds the old parser byte-for-byte
(readUsage/count=bobUsage/bobCount; the stream loop = the oldbobResponseUsage).
readAgentUsagecopies back only the 5 token counts; the oldbobUsagekept every other field
frombasetoo, so the net result is the same.providerusage.Presentis the old
usagePresentbody, unchanged.bobUsage's 5 direct tests run through a test-only shim that
wraps the block as a JSON reply; each old garbage input still returnsbase. - Route gating. Old:
bob := up.path == bobModelPath. New:h.agentFor(up.path). The default
registry holds Bob onbob.ModelPath(init inagent/bob), andbobModelPath = bob.ModelPath
keeps the strings one.static.pathandup.pathare the same string by construction
(comment atproxy/proxy.go:1305). Non-Bob routes getBase, whose methods are the identity —
pinned byTestReadAgentUsageWithTheNeutralAgentIsTheIdentityand
TestNonBobRoutesIgnoreBobCacheWrites. - Fail open. Both recovers log the panic's type only, never its message. The log tests capture
slog.Default()before the request; the request logger derives from it
(proxy/proxy.go:1311), so the assertions read the lines the code writes. - Library rule.
agentandagent/bobimport no host; the guard runsgo list -deps ./...
from the package and fails if either package is missing from the list. - Merge
3ee169ef.git show --ccshows no hand-resolved conflict.main'sproxy/edits
touch lines the stack did not, as the PR body says. - The PR body states the behavior change (none) and the data dependence (metadata only, as
before) at the top, per the repo rules. - I did not run any build or test (live tests not approved; Go is not installed here).
…lock (#1066) A keep-alive ping that missed and re-wrote the cache now moves the refresh clock. The next real request is no longer labeled ttl_expiry when the ping had re-created a live entry. A 2xx ping that read or wrote the cache moves the clock in five places: the scheduled ping (record1), the manual ping (no schedule restart, no credit), the summary substitute, the live restart-grace clock in the dash recorder, and the clock rebuilt after a restart. A ping that billed neither read nor write, or that failed, moves nothing. Behavior change: keep-alive users. Old: a failed ping with CacheRead > 0 moved refreshedAt, and a ping that only wrote the cache did not. New: only a 2xx ping that read or wrote moves it. How to turn it off: no switch. Owner's yes, 2026-11-11, in the integrator session: "u have my approval for 1064 and 1066." Data dependence: metadata only (status codes, cache read and write counts, times). docs/data-dependence.md has the updated row. Fixes #580. Reviews: 2 offload reviews (GLM), round 3, both approve at f08969d, which is the PR head. Main's later change to docs/design.md (#1029) is in a separate hunk; the merge is clean. Signed-off-by: DAVID BOAZ <[email protected]> Assisted-By: Claude (Anthropic AI) <[email protected]>
On IBM Bob's route, Context Guru's own model calls (the summary call and the sweep's question, #1036) now go to Bob's model path with Bob's auth, behind the agent extension point (#1029). Step A2.4, #1030 item 4. - agent: a new method, ModelTarget() (chat Path and AuthScheme). Base returns the zero target: the host default (/v1/chat/completions, Bearer), so every other route is unchanged. The agent never sees the key; the host builds the header. - agent/bob: Bob.ModelTarget returns {bob.ModelPath, "Apikey"}. - cheapmodel: OpenAI gets a Path field. Complete and CompletePrefixedChat post to it. Behavior change, Bob route only. Who: Bob users with a preset that makes model calls (bob-ultrahigh); today's Bob presets (off, lossless) make none. Old: the calls went to /v1/chat/completions with Bearer, failed, and the request went on unchanged. New: they go to /inference/v1/chat/completions with "Authorization: Apikey <caller's key>". Security fix on the same route: a Bob request with no key of its own no longer falls back to the operator's --openai-key, so that key is not sent to Bob's server. The OpenAI route keeps its fallback. Turn it off: use a preset without model calls. Owner's yes, 2026-11-11, in the integrator session: "yes I approve it since we dont have Bob users yet". Data dependence: none changed. Reviews: 3 offload review rounds (Claude backend). Round 3: both approve at b94582a. After it, the integrator merged main (423936e) and retargeted the PR from #1029's branch to main. The PR's own added and removed lines are identical to the approved change (14 files, +492/-12); the hand resolutions in agent/ and docs/design.md keep the branch side. Signed-off-by: Vitaly Zabershinsky <[email protected]> Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5 <[email protected]>
…975) On IBM Bob's route, each reply is labelled with the IBM backend that served it: A, B or other. IBM serves Bob's model route from 2 backends that count tokens differently, so a preset comparison is valid only on one backend. - Behind the agent interface (#1029): agent.Usage gets a Backend field; the label rule, the helper-call skip (models security and router), the counters and the once-per-shape warning live in agent/bob/usage.go; Bob.ReadUsage sets Backend. proxy calls the agent on every reply; when the shared parser found no usage, only Backend comes from the agent and the token counts stay as parsed. - A new dashboard column, backend, and a new /stats top-level key, bob_backend (always present). Behavior change, Bob route only: the dashboard and /stats for Bob traffic. Old: a Bob row had no backend. New: each Bob reply carries the label. A strict /stats parser that rejects unknown keys must allow bob_backend. A new backend that looks like B is labelled B, with no alarm. The label never changes a request. Turn it off: do not set --bob-upstream. Owner's yes, 2026-11-12, in the integrator session: "975 approve"; the port behind agent/bob: "your recommendation". Data dependence: metadata only (a label per request row). Row: docs/data-dependence/features/billed-token-and-cache-time-records.md. Reviews: 5 offload review rounds (Claude backend). Round 5: both approve at 37443f3, which is the PR head, after the integrator's merge of main and the port behind the agent interface. Signed-off-by: Vitaly Zabershinsky <[email protected]> Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5 <[email protected]>
Folded-in PRs
refactor(agent): move Bob's session id into agent/bob. New packageagent/bob;explicitSessionOfasks the route's agent for a session id (fail open on panic).refactor(agent): move Bob's usage reading into agent/bob.agent/bob/usage.goreads Bob's cache-write fields;proxy/agentusage.goreadAgentUsagecopies back only the 5 token counts (fail open on panic). The "usage present" rule is nowinternal/providerusage.Present.Bob code still in
proxy.go, for the next A2 moves: the route setup, the profile and model-info handling, the backend label (#975), the summary-call route, andBobUpstream.Original text by the author:
Summary
This PR adds
agent/, one extension point for client agents such as IBM Bob. Today, per-agent behavior sits inif up.path == bobModelPathbranches inside the sharedproxy/proxy.go, and each new feature adds another. Withagent/, a new agent is one package that embedsBase, overrides only what differs, and registers its routes. The shared code never names an agent.This is step A1. The next step (A2) moves Bob's existing branches out of
proxy.goand behind this interface, one at a time.What we found
Bob-specific branches inside the shared
proxy/proxy.goonmain:Mux;explicitSessionOf, which readsX-Task-Id;bob := up.path == bobModelPathinserve;bobResponseUsageon 2 reply paths;forwardBobProfile.More agents like Bob are expected. Each would add a branch in each of these places, so the shared code would change for every new agent.
What changed
agent/agent.go: theAgentinterface, andBase, the neutral agent.Base(today's behavior)Name()""Paths()nilSessionID(h)""ReadUsage(ct, reply, base)base, unchangedUsageis a neutral copy of the token counts: a library must not importproxy, so the host maps its own type to it and back.agent/registry.go: aRegistryfound by route path, safe for concurrent use. It refuses a nil agent, an empty path, and a path that another agent already claims. A package-levelRegister, for an agent'sinit(), panics on a refusal, ascomponents.Registerdoes.The interface holds only what A2 wires. A method is added when its first caller is.
Basemakes that safe: an agent that embeds it does not break when the interface grows. A summary-call target and a reply label will be added when the code that uses them moves in.Data dependence
None. The package reads nothing and stores nothing.
How it was tested
go test -race ./agent/: OK.go vet,gofmt, andgo build ./...: OK.Basemethod returns today's neutral value. An agent that overrides onlySessionIDkeeps every other method neutral.Base), and the refusals. A concurrentRegisterandForPathtest fails without the lock (DATA RACE).resetDefaultis safe while lookups run. The old version, which swapped the package variable, failed withDATA RACE.TestAgentDoesNotImportAHostfails ifagentimportsproxy,proxyapporcmd/, directly or not. I checked it with a probe file that importsproxy: the test failed.Base.SessionID's""is a no-op insession.Explicit(""is "no candidate"), so A2 can pass it on every route without a change.Open questions