Repository navigation
feat(agent): send CG's own model calls on Bob's route to Bob - #1074
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]>
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]>
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]>
Signed-off-by: DAVID AMID <[email protected]>
The agent interface gets ModelTarget: the chat path and the auth scheme of the host's own calls to the route's model (a summary, the sweep's question). Base returns the zero target, so every other route keeps /v1/chat/completions and Bearer. Bob returns its model path and Apikey. The agent never sees the key; the host builds the header. - cheapmodel.OpenAI gets a Path field. Complete and CompletePrefixedChat both post to it. - The host recovers a panic in ModelTarget and drops a path or a scheme it cannot use safely, so that field keeps the default. - docs: a data-dependence row and the agent/bob design row. Behavior change, on Bob's route only: these calls used to fail there (a path Bob does not serve), and now reach Bob's own server with the caller's own key. 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 | 2e69d0e175d4 |
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
- Merge gates, not code defects. The PR names a behavior change on Bob's route. CLAUDE.md requires a human developer's yes before merge. The new
docs/data-dependence.mdrow has no "Decided by" yet. Both must be closed before merge. agent/bob/bob.go:53— the scheme is alwaysApikey, whatever the caller sent. The forwarded chat request keeps the caller's ownAuthorizationheader unchanged. The side call replaces its scheme withApikey. Two cases differ:- A Bob client that sends
Bearer <key>or a bare key.tenancy.go:245documentsApikeyfor BobShell only. I found no evidence in the repo for what the Bob IDE sends. If it differs, the side call gets a 401 and fails open, so no harm, but no saving. - A caller whose key arrives in
x-api-key(CallerKeychecks it second). The side call sends it asAuthorization: Apikey <key>. - Proposal: add a line on what the Bob IDE sends (a capture, #975), or note this as known.
- A Bob client that sends
proxy/proxy.go:1095-1107— pre-existing: the operator's OpenAI key can go to Bob's host. In single-tenant mode, a Bob request with no caller key makeskey = h.serverKey(h.opts.OpenAIKey). The side call then goes toBobUpstreamwith that key. Before this PR it went there too, withBearer, to/v1/chat/completions. Now it goes asApikeyto Bob's model path. This PR does not make it worse, but the key of one provider still goes to another provider's host. Proposal (separate PR): do not fall back toOpenAIKeywhen the route's upstream is not the OpenAI upstream.proxy/agentmodel.go:24-29— a dropped field is silent. A panic logs. A bad path or scheme is dropped with no log. A developer of a new agent then sees only a non-200 from the upstream. AWarnwith the agent type and the field name (not the value) would help.proxy/agentmodel_test.go:192and:215— the failure message can panic.strings.Fields(got.auth)[0]panics with an index error whengot.authis empty. That only happens on a failing test, but it hides the real failure message.- Not tested end to end: the sweep's question on Bob's route (the PR says so). The trace holds:
chatPrefixAsker(prefixask.go:418-424) copiesmodels.Incoming, whichincomingModelbuilt withPath: target.Pathand theApikeyheader.CompletePrefixedChatposts too.chatPath(). So the ask gets the same target as the summary.
What I checked
- Every changed line of the one commit (14 files, +385/-11), and the commit message and PR body.
agent/agent.go: the new interface method. All agents in the repo embedBase(Bob, the test agents inproxy/agent*_test.go), so the new method breaks none. The package doc tells a new agent to embedBase. No other host (bifrost adapter,proxyapp,cmd/) implementsagent.Agent.cheapmodel/openai.go:chatPath()keeps/v1/chat/completionsfor an emptyPath.AsModelandWithMaxTokenscopy the struct, soPathstays.CompletePrefixedResponseskeeps/v1/responses, which is correct (Bob is a Chat wire).dispatcher.go:120(the configured model) sets noPath, so it keeps the default.proxy/proxy.goincomingModel:h.agentFor(up.path): the OpenAI route hasup.path/v1/chat/completionsand getsBase; only the Bob route hasbob.ModelPath.- Hosted mode with a
key_envon the Bob upstream:keybecomes "" andserverKeyreturns "" in hosted mode, so no client. Same as before. - Without
key_env: the caller's key, found byheaderCredential, which acceptsApikey <key>. The main request forwards that same header, so both exits agree. - The Anthropic branch is unchanged.
Dispatcher.incomingmasks the whole header value and its dedup key covers the full header, so the newApikeyheader is held and masked the same way asBearer.Dispatcher.Dobuilds the URL asTrimRight(up.base, "/") + req.Path.safeTargetPathrejects a relative path,//host, control characters, space,?and#. So a target cannot change the host.httpTokenmatches the RFC 9110 token set, so a scheme cannot add a header.- Fail open:
agentModelTargetrecovers a panic and returns the zero target. It logs only the types, the same pattern asagentusage.goand the session-id recovery. - Tests: the helpers they use exist (
bigToolOutput,captureDefaultLog,panicCanary).h.agentForis read per request, so the test override works. The Bob test asserts path, model and the exact auth header. The OpenAI test asserts the default. The 4 bad-target cases and the panic case assert the default and that the panic text is not logged. I did not run them (live tests not approved; Go is not installed). docs/data-dependence.md: the row has 6 cells, as the table needs, and sits in "Features outside the pipeline".docs/design.md: theagent/bob/row is updated.
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 | 2e69d0e175d4 |
approve |
Verdict: approve
Findings
None. I found no defect in the change.
Non-blocking
- Merge gates are still open. The PR is a behavior change on Bob's route, and the new row in
docs/data-dependence.mdhas no "Decided by". Both need a human developer's yes before merge (CLAUDE.md). The PR says this at the top. This is a reminder, not a code defect. - Pre-existing: the operator's OpenAI key can reach Bob's host. In
proxy/proxy.go:1094-1110, a Bob request with no caller key of its own (or only a token-shaped one) falls back toh.serverKey(h.opts.OpenAIKey). In single-tenant mode with--openai-keyandBobUpstreamset, the summary call then sends the operator's OpenAI key to Bob's upstream. Before this PR it went asBearer. Now it goes asApikey. This PR does not cause it, but it now gives that call a working path. Suggest a follow-up: no server-key fallback on a route whose agent names its own target, or no fallback on the Bob route. It is the same family as the token-length issue in the PR's Technical notes. - Path validation has no test for
?,#, a space or a control character.safeTargetPath(proxy/agentmodel.go:35-40) rejects them, butTestMalformedAgentModelTargetKeepsTheHostDefaultcovers only the relative path and//host. Two more table rows (/x?y,/x#y) would pin the rest. Without the check, a?or#would change the URL's query or fragment, and a mutant that drops only that part of the check would pass the suite. - The sweep's question on Bob's route has no end-to-end test. The PR says so. The chain is short and I traced it:
chatPrefixAskercopiesmodels.Incoming(proxy/prefixask.go:417-423), and the copy keepsPathandRef.AsModelandWithMaxTokenscopy the struct too (cheapmodel/openai.go:41,45), so a remodeled client keeps the target. - Test failure messages can panic. In
proxy/agentmodel_test.go,strings.Fields(got.auth)[0]panics whengot.authis empty. It happens only on a failing run, but it hides the real message.
What I checked
- Read the full diff (14 files) and the one commit. DCO sign-off and
Assisted-Byare present. agent.AgentgainsModelTarget. Every implementer embedsBaseor defines it:Bob, and the test agents inagent/registry_test.go,proxy/agentsession_test.go,proxy/agentusage_test.go,proxy/agentmodel_test.go. No other implementer exists in the repo.agent.ForPathreturnsBase{}for an unknown path, never nil (agent/registry.go:50-57). So non-Bob routes get the zero target and do not hit therecoverpath on every request.incomingModel(proxy/proxy.go:1067-1112): the zero target keepsAuthHeader(OpenAI, key, "")=Bearer. A set scheme buildsAuthorization: <scheme> <key>. The Anthropic branch is unchanged.- Hosted mode: the Bob route gets an injecting upstream, so
keybecomes"",serverKeyreturns"", andincomingModelreturns nil. No change there. Dispatcher.Do(proxy/dispatcher.go:252-320) builds the URL asTrimRight(base, "/") + req.Path.safeTargetPathblocks//hostand query/fragment, so the call stays on the route's own upstream.incomingDedupKeyhashes the auth header, soApikeyandBearerrefs do not share an entry.httpTokenmatches the RFC 9110tcharset. CR, LF and space are rejected.- Fail open:
agentModelTargetrecovers a panic, returns the zero target, and logs only%Tof the agent and the panic value. The test checks the canary is absent from the log. cheapmodel.OpenAI: every Chat call goes throughpostorCompletePrefixedChat, and both now usechatPath().CompletePrefixedResponseskeeps/v1/responses. Bob uses the Chat wire, so that is correct.proxy/dispatcher.go:120(the configured model) leavesPathempty, so it keeps/v1/chat/completions.CallerKeyreadsApikey <key>throughheaderCredential(two fields → the second), so Bob's caller key reaches the summary call.- Tests: Bob route → Bob path,
Apikey <caller key>, the request's own model. OpenAI route → unchanged. Panic → defaults. Four bad targets → defaults. The Bob test relies on the default registry, whichproxyfills through its import ofagent/bob(bobModelPath = bob.ModelPath). - Docs:
docs/design.mdanddocs/data-dependence.mdare updated. The new row is in "Features outside the pipeline", socomponents/all/datadep_test.gois not affected. - I did not run Go builds or tests (not approved for this review).
A Bob request with no key of its own fell back to the operator's OpenAI key for CG's own model calls, and so sent that key to Bob's server. A route whose agent names its own target now gets the caller's key or no model call. The OpenAI route keeps its fallback. - A target field the host drops is logged at Warn: the agent type and the field name, never the value. - Tests: the query, fragment and space path rows; failure messages that cannot panic on an empty auth header. - docs: the data-dependence row says so, and names who decided. Both round-1 reviewers of #1074 raised these points. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Vitaly Zabershinsky <[email protected]>
|
Round 1 replies. Both reviewers approve. Fixed in 4af5098:
Checks: |
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 | 4af50983d0d4 |
approve |
Verdict: approve
Findings
None. The new commit fixes the round-1 points correctly, and I found no new defect.
Round-1 points, one by one
Both reviewers approved in round 1. All points were non-blocking.
| # | Point | Raised by | Status |
|---|---|---|---|
| 1 | Merge gates: human yes, "Decided by" | 1, 2 | Fixed. The owner's reply (2026-11-11T08:09) gives the yes. The row now says "Decided by: Vitaly Zabershinsky, #1074". |
| 2 | Operator's OpenAI key can reach Bob's host | 1, 2 | Fixed. proxy.go falls back to OpenAIKey only when the target is zero. New test TestBobRouteNeverSendsTheOperatorsOpenAIKey checks every upstream call for the canary. TestOpenAIRouteStillFallsBackToTheOperatorsKey pins the old fallback. |
| 3 | No tests for ?, #, space in the path |
2 | Fixed. 3 new table rows. |
| 4 | A dropped field is silent | 1 | Fixed. dropTargetField logs at Warn with the agent type and the field name, not the value. The test checks field=path or field=auth_scheme for each row. |
| 5 | Failure message can panic | 1, 2 | Fixed. authScheme returns "" for an empty value. |
| 6 | Scheme is always Apikey |
1 | Rejected, and I accept the reason. The author says live captures show the Bob IDE sends Apikey <key>, as Bob Shell does. I cannot see those captures. A client with another scheme gets a non-200 and fails open, so the risk is only a lost saving. |
| 7 | Sweep's question on Bob not tested end to end | 1, 2 | No change, accepted. Both traces agree. |
Non-blocking
proxy/proxy.go:1098-1101— the key rule reads the target after the checks.agentModelTargetreturns the zero target when the agent panics, or when it drops both fields. Thentarget == (agent.ModelTarget{})is true, and the operator'sOpenAIKeyfallback comes back on that agent's route. Today no real case exists: Bob does not panic, and its target is valid. A future agent with a bad target would, in single-tenant mode, send the operator's key to its own upstream, at/v1/chat/completions. Proposal: decide on the upstream, not the target (for exampleup.base == h.opts.OpenAIUpstream), or on whether the route has an agent other thanBase. A follow-up is enough.- The fix is a small behavior change of its own. On Bob's route with no caller key, the old code made a call with the operator's key (it failed at Bob). The new code makes no call. The owner approved it, and the data-dependence row says so. I note it only so the PR's top note can name it too.
What I checked
- Last review: round 1,
2e69d0e175d49e56c95b5c0671488c6df079f2f1, 2026-11-11T07:56:08Z - New commits read: 1 —
4af50983fix(agent): never send the operator's OpenAI key to an agent's target (4 files, +76/-10) - 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 (07:56:17Z): I read it. Its points are 1, 2, 3, 5, 7 in the table above. I checked each fix.
- The author's reply (08:09:01Z): I checked each of its 7 items against the diff. See the table.
proxy/proxy.goincomingModel: the target is now computed before the key fallback. Hosted mode is unchanged (serverKeyreturns "" there). The Anthropic branch is unchanged. The OpenAI route's agent isBase, so its target is zero and the fallback stays.proxy/agentmodel.go: an empty field is no longer "dropped", soBasedoes not log a Warn on every request. Only a non-empty bad field logs. The log has the type and field name only.proxy/agentmodel_test.go:postSummarizablesets noAuthorizationheader whenauthis "". The new tests use that.captureDefaultLoguses a text handler, sofield=pathis the real output form. Subtests do not run in parallel, so swapping the default logger is safe.- The Bob canary test checks both the header and the body of every call, and also expects 0 summary calls.
docs/data-dependence.md: the row keeps 6 cells and adds the key rule and "Decided by".- I did not run Go builds or tests (not approved for this review). The author reports
go test -raceandgo vetOK.
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 | 4af50983d0d4 |
approve |
Verdict: approve
Findings
None. The new commit fixes the round-1 points, and I found no new defect.
Status of round-1 points
Neither reviewer had a blocking finding in round 1. These are the non-blocking points:
- Merge gates (both reviewers): closed. The PR's top note and the author's comment say the repo owner approved the behavior change on 2026-11-11. The data-dependence row now has
Decided by: Vitaly Zabershinsky, #1074. I cannot check the approval myself. The PR author's account posted it, and only a human can confirm it. - Operator's OpenAI key to Bob's host (both): fixed.
proxy/proxy.go:1101uses the operator's key only when the target is zero.TestBobRouteNeverSendsTheOperatorsOpenAIKeysends a canary key and checks that no upstream request carries it, in a header or in the body.TestOpenAIRouteStillFallsBackToTheOperatorsKeyshows that the OpenAI route keeps its fallback. - No tests for the
?and#path checks (mine): fixed. There are new rows for?,#and a space. - No log when a field is dropped (reviewer 1): fixed.
dropTargetFieldlogs at Warn with the agent type and the field name only. Each malformed-target row checks for the log and itsfield=value. - Failure message can panic (both): fixed. The
authSchemehelper returns "" for an empty header. - The scheme is always
Apikey(reviewer 1): the author rejected it. The reason is live captures of Bob IDE traffic. I accept it: a wrong scheme only gives a non-200, and the request goes on unchanged (fail open). - No end-to-end test of the sweep's question on Bob (both): no change, accepted. Both traces agree.
Non-blocking
- The key rule uses the target after it is cleaned, not the route. At
proxy/proxy.go:1098-1101, the target is zero in two more cases: the agent'sModelTargetpanics, or the host drops every field. Then a route that an agent owns falls back to the operator's OpenAI key again, withBearer, on that route's upstream. No agent in the repo does this today: Bob returns a fixed, valid target. But the data-dependence row says "Such a route never uses the operator's OpenAI key", and it is true only while the agent behaves. A stronger rule: use the operator's key only whenh.agentFor(up.path)is the neutral agent, or when the upstream is the OpenAI upstream. A follow-up is enough. - The doc comment of
incomingModel(proxy/proxy.go:1043-1066) does not yet say that an agent route gets no server-key fallback. A one-line note there would keep that comment correct.
What I checked
- Last review: round 1, 2e69d0e, 2026-11-11T07:56:17Z
- New commits read: 1 (
4af50983fix(agent): never send the operator's OpenAI key to an agent's target) - Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
- New items since my last review:
- Commit
4af50983: I read all 4 files and the code around each change (see below). - The author's comment at 08:09:01Z, with replies 1-7: I checked each reply against the code above.
- The changed PR body top note (approval and the key fix): I noted that I cannot check the approval.
- Reviewer 1's round-1 review (07:56:08Z, posted before mine, read now): I checked its points above. I do not repeat them.
- Commit
incomingModel: the code now callsagentModelTargetbefore the key check, so it runs once for every OpenAI-wire request. It is cheap and cannot fail the request. The Anthropic branch and hosted mode do not change:serverKeystill returns "" when tenants are set.agentModelTarget: an empty field now skips the check, so the zero target does not log a Warn on every request. This is correct, because before the fixsafeTargetPath("")andhttpToken("")were false, and that is why the new!= ""guards are needed for the log.- Tests: in
postSummarizable,auth == ""sends no Authorization header, soCallerKeyreturns "". That is the no-key case the new tests need. The malformed-target subtests run one after the other, socaptureDefaultLogswaps the default logger safely. docs/data-dependence.md: the row text agrees with the code, with the gap that the first non-blocking point describes.- I did not run Go builds or tests (not approved for this review).
The key rule read the target after the host cleaned it. An agent whose ModelTarget panicked, or whose fields were all dropped, gave the zero target, and its route fell back to the operator's OpenAI key again. agentModelTarget now also reports whether the agent owns its route's auth: it named a target, or it panicked. An owned route gets the caller's key or no model call. Both round-2 reviewers of #1074 raised this point. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Vitaly Zabershinsky <[email protected]>
|
Round 2 replies. Both reviewers approve. Fixed in b94582a:
The repo owner granted 1 more review round (round 3) for this fix. Checks: |
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 | b94582ab2001 |
approve |
Verdict: approve
Findings
None. The new commit closes the round-2 gap, and I found no new defect.
Round-2 points, one by one
Both reviewers approved in round 2. All points were non-blocking.
| # | Point | Raised by | Status |
|---|---|---|---|
| 1 | The key rule reads the cleaned target, so a panicking agent or an agent with only bad fields gets the operator's key again | 1, 2 | Fixed. agentModelTarget returns owned. It is true when the raw target is not zero, and the recover sets it true on a panic. incomingModel uses the operator's key only when !owned. |
| 2 | The incomingModel doc comment does not state the rule |
2 | Fixed. proxy.go:1065-1066 states it. |
| 3 | The fix is a small behavior change of its own | 1 | Named. The author says the PR's top note names it, and the owner approved it. |
Non-blocking
ownedmeans "the agent named a target", not "this is not the OpenAI upstream". A future agent on a non-OpenAI upstream that keeps the zero target (it needs onlyBase's path andBearer) still gets the operator's OpenAI key. No such agent exists today: Bob names a target. The doc comment atagentmodel.go:15-17says whatownedmeans, so the rule is clear to the next agent author. A follow-up can add a check on the upstream if one comes.
What I checked
- Last review: round 2,
4af50983d0d470d6758b7a2006c7a3fca10445df, 2026-11-11T08:10:18Z - New commits read: 1 —
b94582abfix(agent): a misbehaving agent's route gets no operator key either (3 files, +47/-7) - 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 (08:10:29Z): I read it. Its two points are 1 and 2 in the table. I checked both fixes in the code.
- The author's round-2 reply (08:39:05Z), items 1-3: I checked each against the diff. It also says the owner granted round 3. I cannot check that grant; the author's account posted it.
- Commit
b94582ab: see below.
proxy/agentmodel.go:ownedis set from the raw target before the field checks, so a target with only bad fields still counts as owned.- On a panic, the deferred
recoversetst, owned = zero, true. The named results carry it out. So a panic fails closed for the key and fails open for the call target. Basereturns the zero target, soownedis false and the OpenAI route keeps its fallback.
proxy/proxy.goincomingModel: the rule iskey == "" && !owned. Hosted mode is unchanged (serverKeyreturns ""). The Anthropic branch is unchanged.proxy/agentmodel_test.goTestAMisbehavingAgentRouteNeverSendsTheOperatorsOpenAIKey:- On the OpenAI route with
OpenAIKeyset,bearerKeygives a non-nilsetKey(proxy.go:994-998). Sokeybecomes "" and the test reaches the fallback branch. That is the case under test. - The main chat request legitimately carries the operator's key to this upstream. The test checks only the summary calls (
got), so it does not fail on that request. It checks both that no summary call carries the key and that there are 0 summary calls. - The two cases (a panic, and both fields bad) cover both ways
ownedis true while the target is zero.
- On the OpenAI route with
- I did not run Go builds or tests (not approved for this review). The author reports
go test -raceandgo vetOK.
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 | b94582ab2001 |
approve |
Verdict: approve
Findings
None. The new commit fixes the round-2 points, and I found no new defect.
Status of round-2 points
Both reviewers approved in round 2. All points were non-blocking.
- The key rule reads the target after it is cleaned (both reviewers): fixed.
agentModelTargetnow also returnsowned.ownedis true when the agent named a target. A target that the host then drops still counts (proxy/agentmodel.go:28).ownedis also true whenModelTargetpanics. The deferredrecoversets it (proxy/agentmodel.go:24).incomingModeluses the operator's key only when!owned(proxy/proxy.go:1104).TestAMisbehavingAgentRouteNeverSendsTheOperatorsOpenAIKeycovers both cases. It checks for the canary key, and it checks that 0 summary calls go out.
- The
incomingModeldoc comment (mine): fixed. It now says that a route whose agent owns its auth never gets the server-held OpenAI key (proxy/proxy.go:1065-1066). - The key fix is a small behavior change (reviewer 1): named. The PR's top note names it, and the author's reply says the owner approved it. Only a human can confirm that approval. I cannot check it from the PR.
Non-blocking
- The new test checks for the canary key only in the summary calls (
got), not in every upstream call.TestBobRouteNeverSendsTheOperatorsOpenAIKeychecks every call. This is enough here, because the test also needslen(got) == 0. A summary call that leaked the key would also fail that check.
What I checked
- Last review: round 2, 4af5098, 2026-11-11T08:10:29Z
- New commits read: 1 (
b94582abfix(agent): a misbehaving agent's route gets no operator key either) - Read in full: 4 reviews, 2 comments, 0 inline comments (from the three files)
- New items since my last review:
- Commit
b94582ab: I read all 3 files and the code around each change (see below). - Reviewer 1's round-2 review (08:10:18Z): its key-rule point is the same as mine, and the new commit fixes it. I checked its behavior-change point above.
- The author's reply at 08:39:05Z (items 1-3, and the extra round 3 that the owner granted): I checked each item against the diff.
- Commit
agentModelTarget:ownedis computed from the raw target, before the checks, so a dropped field still counts as owned.- On a panic,
owned = t != ...never runs, and the deferred function setsownedto true andtto the zero target. Basereturns the zero target, so the neutral agent is not owned. The OpenAI route keeps its fallback, andTestOpenAIRouteStillFallsBackToTheOperatorsKeystill covers that.
incomingModel:ownedis used only for the server-key fallback.- A caller's own key still works on an owned route.
TestPanickingAgentModelTargetFailsOpenToTheHostDefaultsends a caller key, and it still expects one summary call with the default path and auth. - Hosted mode and the Anthropic branch do not change.
- Fail open: a misbehaving agent's route without a caller key now gets no model client. The component falls back to its rule-based path, and the request still goes out. It fails closed for the key only, which is the right direction.
- I did not run Go builds or tests (not approved for this review). The author reports that
go test -raceandgo vetpass.
Hand resolutions: agent/ files keep the branch side (identical to main plus #1074's change); docs/design.md keeps the agent/bob row with ModelTarget. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
Integrator note: the integrator merged
|
#1074 and #1068 added rows to docs/data-dependence.md after this branch. They are now files under docs/data-dependence/features/, and the page is rebuilt by the generator. Both tables equal main's tables. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
…ce.md (#1090) docs/data-dependence.md is now built from one file per row, so two PRs that change different rows never edit the same source file. - Row files: docs/data-dependence/components/<name>.md (24, the file name is the component name) and docs/data-dependence/features/ <slug>.md (28 + 2 new from #1068 and #1074). key: value lines between two --- lines, then the reason as the body. An optional order number keeps the page order. - The page text lives in docs/data-dependence/page.md.tmpl. - cmd/gen-datadep (parser in internal/datadep) writes the page; make datadep runs it. The page stays checked in (owner's choice). - A drift test fails when the page is out of date, and names the command. components/all/datadep_test.go keeps every guard on the row files: a registered component without a file, a file for an unknown or misspelt component, a missing reason. - On a conflict in the generated page: take either side and re-run the generator. RELEASING.md says this is not a hand resolution. - CLAUDE.md, RELEASING.md, the PR template and the offload-review reviewer prompt describe the new process. Behavior change: none (docs, tests, a generator). Data dependence: none; the rows' content is unchanged. Closes #1088. Reviews: 2 offload reviews (GLM), round 2, both approve at 98d6383, which is the PR head. Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5 <[email protected]>
…fault (#973) The Bob plugin replaces its lossless-defer preset with bob-ultrahigh, and bob-ultrahigh becomes the default Bob preset. bob-ultrahigh is context-guru's ultrahigh preset with 4 Bob changes; a test pins that it cannot drift from ultrahigh. It keeps the tool deferral (-17.7% input per turn on real Bob tasks). Since #1074, its summary calls reach Bob's /inference/v1/chat/completions with the user's own key and quota. setup --plan names what the default does before the user agrees: it stores content on the Mac (originals, summaries and held answers), sends summary calls to Bob with the user's own key and quota, and uses Bob's flat prices on the dashboard. It says how to choose lossless. Behavior change: every new Bob install. Old: the default preset was lossless. New: bob-ultrahigh. Turn it off: configure --preset lossless. Owner's yes, 2026-11-11, in the integrator session: "there are no bob users and bob-ultrahigh is the new default", then "bob-ultrahigh". Data dependence changes: the default Bob install now keeps stored content on the user's Mac. Owner's confirmation, 2026-11-11: "1 okey. this happens on ultrahigh as well afaik". Rows: docs/data-dependence/features/bob-plugin.md and components/toolfilter.md. Reviews: 6 offload review rounds (Claude backend; round 6 after the default change). Round 5: both approve at 81dba55. Round 6 blocked on two points: a setup release check for a proxy older than v0.7.2, which the owner ruled moot on 2026-11-12 ("there is no older proxy for bob this is moot point"), and a missing human yes on the PR, answered by the integrator's comment with the owner's quotes. 1dbbe6a has the same tree as 1bdf248 (a clean merge of main into 971deb1). Signed-off-by: Vitaly Zabershinsky <[email protected]> Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5 <[email protected]>
…ts (#1112) The agentmodel tests (from #1074) now wait for the detached summary call before they count the upstream's calls, with a time limit. Since #1073 the summary call runs off the request path, so a fixed check raced it and failed now and then in CI (TestOpenAISummaryCallTargetIsUnchanged, TestMalformedAgentModelTargetKeepsTheHostDefault). Test only. Behavior change: none. Data dependence: none. Fixes #1110. Reviews: 2 offload review rounds (Claude backend). Round 2: both approve at 0b3a6a0, which is the PR head. Signed-off-by: Vitaly Zabershinsky <[email protected]> Assisted-By: Claude Opus 5.5 <[email protected]>
Summary
This is step A2.4, and #1030 item 4: the incoming model client gets Bob's path and auth. David's #1036 notes that the sweep's question on Bob "still fails open (wrong path and auth) until item 4". This PR is that fix, behind the agent extension point (#1029), with no Bob code in the shared path.
What changed
agent: a new method,ModelTarget() ModelTarget.ModelTargetholds the chatPathand theAuthSchemeof the host's own calls to the route's model.Basereturns the zero target. A zero field means the host default (/v1/chat/completions,Bearer), so every other route is unchanged.agent/bob:Bob.ModelTargetreturns{bob.ModelPath, "Apikey"}.cheapmodel:OpenAIgets aPathfield (empty means/v1/chat/completions).Complete(the summary call) andCompletePrefixedChat(the sweep's question, #1036) both post to it.proxy:incomingModelasks the route's agent for its target.chatPrefixAskercopies that client, so the sweep's question gets the same target.agentModelTargetrecovers a panic and gives the defaults. The log names the types only.//, or holds a space, a control character,?or#; a scheme that is not one HTTP token.Data dependence
No component sends or stores anything new. On Bob's route, the summary call and the sweep's question now reach Bob's own server, with the caller's own key, and no other place.
docs/data-dependence.mdhas a new row for this, under "Features outside the pipeline". Decided by: Vitaly Zabershinsky.How it was tested
go test -raceon./proxy/ ./agent/... ./cheapmodel/ ./components/... ./apply/: OK (proxy 576 s).go vet ./...,gofmt,go build ./...: OK.ModelTargetandPathdid not exist):agent:Base.ModelTargetis the zero target.agent/bob: Bob's target is its model path withApikey.cheapmodel:CompleteandCompletePrefixedChatpost toPath, and to/v1/chat/completionswhen it is empty.proxy, end to end with a fake upstream:Apikey <caller key>and the request's own model;/v1/chat/completionsandBearer;ModelTargetpanics: the request succeeds, the call keeps the defaults, and the panic text is not in the log;//hostpath,?,#, a space in the path, a scheme with a space, a scheme with a line break) keep the defaults, and each is logged;recover;?and#check.Technical notes
models.Incoming) as the summary call, andCompletePrefixedChatis tested onPath.main: a Context Guru token of the wrong length in an auth header can become the key of a summary call on any route.CallerKeyskips only a token of the exact shape. The forwarded request removes the token, but the summary call does not. The fix is a small, separate PR, because it changes an edge case on every route.BobUpstream, and the backend label (feat(proxy): label each Bob reply with the IBM backend that served it #975, not merged yet).