Skip to content

feat: redesign as context-guru — provider-agnostic context-engineering#4

Merged
OsherElhadad merged 6 commits into
mainfrom
feat/context-guru
Jul 12, 2026
Merged

feat: redesign as context-guru — provider-agnostic context-engineering#4
OsherElhadad merged 6 commits into
mainfrom
feat/context-guru

Conversation

@OsherElhadad

Copy link
Copy Markdown
Collaborator

What

Greenfield redesign of this repo into context-guru: a provider-agnostic context-engineering library (built on bifrost's chat schema) that reduces LLM-agent token cost, with one core behind two hosts — the context-guru-proxy (also the eval-containers gateway) and the AuthBridge in-process plugin.

Highlights

  • Component model split by lossiness: Reformat (lossless) vs Offload (drops bytes, must stash a recoverable original). Config-ordered, fail-open, never-worse pipeline; name→constructor registry (add a component → YAML-configurable, no core edit).
  • Anthropic tool_result support — Claude Code sends tool outputs as tool_result blocks inside user messages, which bifrost's schema can't represent. apply normalizes them to synthetic tool messages, runs the pipeline, and splices rewrites back byte-losslessly (siblings/tool_use_id preserved). Validated live against claude-sonnet-4-6.
  • Reversibility: <<cg:HASH>> markers + store + a model-callable expand tool loop (proxy handles OpenAI + Anthropic continuation).
  • Honest metrics: token-weighted + bounce-adjusted savings, top_passthrough dead-weight signal, per-component accounting.
  • Docs rewrite with mermaid diagrams: README + docs/{design,components,integrations,setup}.md, including per-component deep-dives and a real SWE-bench + Claude Code run.
  • eval-containers gateway harness (deploy/eval-containers/): Dockerfile, gateway start, compose override, resumable sweep.py + aggregate.py.

Correctness & tests

  • Fixed review findings incl. a real bug where skeleton rewrote non-tool messages' own code; the cache-safety lossless-splice guard; malformed expand continuations; misleading top_passthrough.
  • Coverage raised (schema 41→94%, config 47→85%, expand 58→90%, store/session 0→100%; offload/reformat ~81% via -coverpkg). go build/vet/test all green; gofmt clean.

Early benchmark results (SWE-bench, Claude Code, claude-sonnet-4-6)

  • Zero reward regression: every task the baseline resolved stayed resolved under context-guru.
  • balanced preset: ~12% content-token savings on resolved tasks (up to ~23%), driven mainly by failed_run collapsing superseded test/build runs.

Follow-ups (tracked, not in this PR)

  • Inject the expand tool into outgoing requests + streaming-safe recovery (unlocks the lossy offloaders — skeleton/collapse/mask — on Claude Code's file-read-heavy traffic).
  • Competitor comparison: headroom gateway wiring; RTK needs per-task agent images built.

Osher-Elhadad added 2 commits July 12, 2026 11:01
Greenfield provider-agnostic context-engineering library built on bifrost's
chat schema. Split-by-lossiness component API (Reformat vs Offload), a
config-ordered fail-open never-worse pipeline, name->constructor registry,
in-memory TTL+LRU store, marker + model-callable expand reversibility, and
honest bounce-adjusted metrics. One shared apply path drives two hosts: the
context-guru-proxy (also the eval-containers gateway) and the AuthBridge
in-process plugin. Handles Anthropic tool_result tool outputs by normalizing
them to synthetic tool messages and splicing rewrites back byte-losslessly.
Includes rewritten docs with diagrams and the eval-containers SWE-bench
gateway harness.

Assisted-By: Claude (Anthropic AI)
Signed-off-by: Osher-Elhadad <Osher.Elhadad@ibm.com>
Signed-off-by: Osher-Elhadad <Osher.Elhadad@ibm.com>

# Conflicts:
#	README.md
#	cmd/proxy/main.go
#	internal/proxyhttp/proxy.go
#	internal/proxyhttp/proxy_test.go
@OsherElhadad OsherElhadad merged commit 4d357ce into main Jul 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants