Documentation
¶
Overview ¶
Package bifrost adapts context-guru's pipeline to bifrost's LLMPlugin interface: our components run as a pre-LLM-call hook (design D2). Registering this plugin via BifrostConfig.LLMPlugins is all it takes for an embedded bifrost proxy — or any bifrost deployment — to run context engineering.
The same components package backs another in-process sidecar plugin (P3); only this thin adapter is bifrost-specific.
Index ¶
- Constants
- type Plugin
- func (*Plugin) Cleanup() error
- func (*Plugin) GetName() string
- func (p *Plugin) PostLLMHook(_ *bschemas.BifrostContext, resp *bschemas.BifrostResponse, ...) (*bschemas.BifrostResponse, *bschemas.BifrostError, error)
- func (p *Plugin) PreLLMHook(_ *bschemas.BifrostContext, req *bschemas.BifrostRequest) (*bschemas.BifrostRequest, *bschemas.LLMPluginShortCircuit, error)
- func (p *Plugin) PreRequestHook(ctx *bschemas.BifrostContext, req *bschemas.BifrostRequest) error
Constants ¶
const BypassContextKey bschemas.BifrostContextKey = "context-guru-bypass"
BypassContextKey lets a caller disable the pipeline for one request (x-context-guru-bypass header -> context value).
const SessionContextKey bschemas.BifrostContextKey = "context-guru-session"
SessionContextKey is the BifrostContext value key the transport sets from the x-context-guru-session header (or Anthropic metadata.user_id). Absent -> the plugin falls back to a content hash.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Plugin ¶
type Plugin struct {
// CheapModel is the static "config"-source LLM for NeedsModel components. The
// bifrost host has no usable "incoming" client (the agent's key is a
// placeholder), so only the static source is offered here. Optional.
CheapModel components.Model
// contains filtered or unexported fields
}
Plugin runs the context-guru pipeline in PreRequestHook. It implements bifrost's schemas.LLMPlugin. It never aborts a request (fail-open): any component failure is already contained inside the pipeline.
func New ¶
func New(pipe *components.Pipeline, st store.Store) *Plugin
New builds the adapter from an already-constructed pipeline and store.
func (*Plugin) PostLLMHook ¶
func (p *Plugin) PostLLMHook(_ *bschemas.BifrostContext, resp *bschemas.BifrostResponse, e *bschemas.BifrostError) (*bschemas.BifrostResponse, *bschemas.BifrostError, error)
func (*Plugin) PreLLMHook ¶
func (p *Plugin) PreLLMHook(_ *bschemas.BifrostContext, req *bschemas.BifrostRequest) (*bschemas.BifrostRequest, *bschemas.LLMPluginShortCircuit, error)
PreLLMHook and PostLLMHook are pass-throughs today; the expand continuation loop lives in the transport wrapper (it must re-invoke upstream, which a hook cannot). Kept here to satisfy the LLMPlugin interface.
func (*Plugin) PreRequestHook ¶
func (p *Plugin) PreRequestHook(ctx *bschemas.BifrostContext, req *bschemas.BifrostRequest) error
PreRequestHook runs the pipeline over the chat request's messages. This is the canonical mutate-the-request phase: changes are committed and seen by the provider call and every fallback. Non-chat requests pass through untouched.