Fix: Address context-guru plugin review feedback (#660)#672
Conversation
📝 WalkthroughWalkthroughContextGuru now validates static model configuration, requires session identity before compaction, and tests sentinel and no-session behavior. Its plugin binaries use explicit opt-in build tags. The demo adds configurable model settings, resource limits, pinned images, and clearer pod failure handling. ChangesContextGuru integration
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Follow-up to the merged context-guru plugin (rossoctl#660), addressing the non-blocking review comments from @mrsabath and @huang195. Plugin (authlib/plugins/contextguru): - OnRequest now skips compaction when there is no session identity instead of falling back to an empty ("") engine-store key, which would bleed per-session compaction state across unrelated callers. - Configure fails loud when exactly one of model.base_url / model.model is set (previously it silently degraded to deterministic — a typo'd or empty ${VAR} expansion would disable the cheap model with no error). - Add unit tests for the sentinel-header recursion guard (the one safety-critical branch) and the no-session skip. Build footprint: - Make context-guru opt-IN (//go:build include_plugin_contextguru) rather than opt-out. Its embedded engine pulls a large transitive set (bifrost/core, tiktoken-go, tree-sitter grammars, starlark), so the default authbridge-proxy/-envoy binaries stay lean (~16 MB smaller) and only pay for it when built with -tags include_plugin_contextguru. Documented in authbridge/CLAUDE.md as the deliberate exception to the exclude_plugin_* convention. Demo (demos/context-guru): - Remove the hardcoded internal IBM VPC endpoint from run.sh and agent.yaml; require CG_MODEL_BASE (fail-loud like CG_MODEL_KEY) and wire it into the deployment via kubectl set env, so no real endpoint lands in the repo. agent.yaml ships a neutral placeholder. - Harden the drive() poll loop: break on terminal pod phases (Failed/Unknown) with a readable error + describe/logs instead of piping crashed-pod logs into json.loads. - Add modest resources requests/limits to both demo containers so the manifest doubles as a usable template. - run.sh builds with -tags include_plugin_contextguru for the opt-in plugin. Supply-chain / hardening: - Digest-pin the envoy:v1.37.1 builder stage in the envoy Dockerfile (parity with the other stages). - Digest-pin alpine:3.20 in run.sh's generated demo Dockerfile. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Osher-Elhadad <Osher.Elhadad@ibm.com> Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
6e0ab58 to
5b7f89f
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@authbridge/CLAUDE.md`:
- Around line 17-20: Update the Envoy entry in CLAUDE.md to state that
ContextGuru is opt-in there as well, requiring the include_plugin_contextguru
build tag, and replace or qualify the “Full plugin set” wording so it does not
imply ContextGuru is included by default.
In `@authbridge/demos/context-guru/run.sh`:
- Around line 33-35: Update the build flow in the run script to create a unique
temporary directory with mktemp -d, use that directory directly as the Go build
output location, and remove the predictable /tmp/cg-img assignment and
subsequent cp step. Preserve the existing binary name and build options.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 2ca6be6c-ce2f-413f-ac14-143f9373c55f
📒 Files selected for processing (9)
authbridge/CLAUDE.mdauthbridge/authlib/plugins/contextguru/plugin.goauthbridge/authlib/plugins/contextguru/plugin_test.goauthbridge/cmd/authbridge-envoy/Dockerfileauthbridge/cmd/authbridge-envoy/plugins_contextguru.goauthbridge/cmd/authbridge-proxy/plugins_contextguru.goauthbridge/demos/context-guru/README.mdauthbridge/demos/context-guru/k8s/agent.yamlauthbridge/demos/context-guru/run.sh
huang195
left a comment
There was a problem hiding this comment.
Review summary
Follow-up that cleanly addresses the #660 review feedback. I reviewed all 9 changed files in full; all 18 CI checks pass and the security-motivated changes verify end to end.
Verified
Configurenow fails loud when exactly one ofmodel.base_url/model.modelis set, and degrades only when both are empty — switch logic is correct.OnRequestskips compaction when there is no session identity, fixing the shared empty-store-key state bleed @mrsabath flagged;sidis reused consistently (log line included).- Three new tests (sentinel short-circuit, no-session skip, partial-model reject) are assertive with no hidden skips.
- Build-tag flip to opt-in (
include_plugin_contextguru) is consistent across bothcmd/*/plugins_contextguru.gofiles and documented inauthbridge/CLAUDE.md+ the demo README. - Hardening lands: digest-pinned
envoy:v1.37.1andalpine:3.20, and the model-key Secret is created via--from-file=key=<(printf %s …)— valid, sincerun.shis#!/usr/bin/env bashwithset -euo pipefail, so the key stays out of argv. - Internal IBM VPC endpoint fully removed from
run.shandagent.yaml;authbridge-config.yamlreads${CG_MODEL_BASE}, so no real host remains anywhere in the repo. drive()breaks on terminal pod phases before piping intojson.loads, fixing the crashed-pod-into-parser path.
One optional nit inline. Well-scoped, well-documented PR — thanks!
Assisted-By: Claude Code
| ```bash | ||
| export CG_MODEL_KEY=<api key for the extract-code model> # e.g. an OpenAI-compatible key | ||
| export CG_MODEL_KEY=<api key for the extract-code model> # e.g. an OpenAI-compatible key | ||
| export CG_MODEL_BASE=https://api.openai.com # any OpenAI-wire endpoint |
There was a problem hiding this comment.
nit (optional): the Run it block exports CG_MODEL_KEY and CG_MODEL_BASE but not CG_MODEL_NAME, which run.sh defaults to gpt-4o-mini. If someone points CG_MODEL_BASE at an OpenAI-wire proxy that doesn't serve gpt-4o-mini (e.g. a litellm gateway with custom model names), the extract-code calls fail with a confusing error. Consider a one-line note here that CG_MODEL_NAME is overridable.
Summary
Follow-up to the merged context-guru plugin (#660), addressing the non-blocking
review feedback from @mrsabath and @huang195. No behavior change to the compaction
path itself — these are correctness, isolation, footprint, and hardening fixes plus
the two review-requested tests.
Relates to epic #659 and issue #641. Builds on #660 (merged).
What changed, mapped to review comments
Plugin (
authlib/plugins/contextguru)sessionIDfalls back to"", so sessionless callers share one engine-store key and bleed compaction stateOnRequestnow skips compaction when there is no session identity (returnsContinue, logs at DEBUG) instead of using the""key.sessionIDdoc updated.TestOnRequest_SentinelHeader_ShortCircuits(assertsContinue+ no body mutation whenX-Context-Guru-LLMis set) andTestOnRequest_NoSession_Skips.Configuresilently degrades if only one ofmodel.base_url/model.modelis setConfigurenow fails loud when exactly one is set (a typo'd/empty${VAR}expansion no longer silently disables the cheap model). Empty-both still degrades intentionally. Covered byTestConfigure_RejectsPartialModel.Build footprint
//go:build include_plugin_contextguru. Defaultauthbridge-proxy/-envoybinaries no longer link context-guru (≈16 MB smaller, 29 MB → 45 MB only with the tag; 0 vs 312 context-guru symbols). Documented inauthbridge/CLAUDE.mdas the deliberate exception to theexclude_plugin_*convention.run.shand the demo Dockerfile build with-tags include_plugin_contextguru.Demo (
demos/context-guru)CG_MODEL_BASEhardcodes an internal IBM VPC endpoint in a public reporun.shandagent.yaml.CG_MODEL_BASEis now required (fail-loud likeCG_MODEL_KEY) and wired into the deployment viakubectl set env;agent.yamlships a neutralhttps://api.openai.complaceholder. No real endpoint lands in the repo.drive()poll loop pipes a crashed pod's logs intojson.loadsFailed/Unknown) with a readable error +describe/logsand a non-zero exit.resourcesSupply-chain / hardening (review-body nits, @mrsabath)
envoy:v1.37.1builder stage incmd/authbridge-envoy/Dockerfile(parity with the other three stages).alpine:3.20inrun.sh's generated demo Dockerfile.run.shnow creates the model-key Secret via--from-file=key=<(printf %s …)(a shell builtin) instead of--from-literal, so the key never transitskubectl's argv / the process table on a shared host.Two go.mod nits that can't be fixed on our side (@huang195)
Both are transitively forced by
bifrost/core v1.7.0(pulled by context-guru); I verified and reverted:go 1.26+toolchain go1.26.4split —go mod tidyimmediately rewrites thegodirective back togo 1.26.4because a dependency requires that exact patch. The idiomatic split isn't achievable while depending on bifrost.protobuf→ stablev1.36.11—go get google.golang.org/protobuf@v1.36.11downgrades bifrost tov1.5.16and drops context-guru;go mod tidythen restores context-guru → bifrostv1.7.0→protobuf v1.36.12-pre. The pre-release is pinned upstream.Both resolve once bifrost/context-guru pins a stable protobuf and relaxes its
godirective; tracked as the "pin to a tagged release" follow-up already noted in #660.Testing
go test ./authlib/plugins/contextguru/...— pass (incl. the 3 new tests).-tags include_plugin_contextgurubuild — both clean forauthbridge-proxyandauthbridge-envoy, in workspace andGOWORK=off(Docker/CI) modes.go vet+gofmtclean.Result (re-validated end-to-end with the opt-in build)
Same agent, same
llama3.2pinned to a 12,288-token window, same task:context-guru remains the only variable that flips the answer from wrong to right — now proven with the opt-in (
include_plugin_contextguru) image.Assisted-By: Claude (Anthropic AI) noreply@anthropic.com