Documentation
¶
Overview ¶
Package apply is the one place the pipeline meets a raw wire request, shared by every host adapter (the bifrost proxy and the AuthBridge plugin). It extracts the messages array, runs the pipeline on it, and splices the result back into the original body — byte-lossless for every other field (headroom invariant I1). This is what makes "one implementation behind both integrations" concrete: hosts differ only in how they obtain the body, provider, and session id.
Provider normalization. Components operate on OpenAI-shaped tool outputs (role=="tool" messages with string content). The Anthropic Messages API instead carries tool outputs as `tool_result` content blocks INSIDE user messages — a shape bifrost's ChatContentBlock cannot even represent (it drops the payload on unmarshal). So for Anthropic requests we expand each tool_result block into a synthetic role=tool message the existing components already know how to shrink, run the pipeline, then splice each rewritten tool output back into its exact source block via sjson. Everything the pipeline did not touch stays byte-identical.
Index ¶
- func Body(ctx context.Context, pipe *components.Pipeline, st store.Store, ...) ([]byte, bool)
- func BodyFull(ctx context.Context, pipe *components.Pipeline, st store.Store, ...) (result []byte, changedBody bool)
- func BodyWithModel(ctx context.Context, pipe *components.Pipeline, st store.Store, ...) ([]byte, bool)
- func BodyWithModelWindow(ctx context.Context, pipe *components.Pipeline, st store.Store, ...) ([]byte, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Body ¶
func Body(ctx context.Context, pipe *components.Pipeline, st store.Store, provider bschemas.ModelProvider, body []byte, explicitSession string, bypass bool) ([]byte, bool)
Body runs the pipeline with no LLM clients available (deterministic components only). See BodyWithModel to supply model clients for LLM-based components.
func BodyFull ¶
func BodyFull(ctx context.Context, pipe *components.Pipeline, st store.Store, provider bschemas.ModelProvider, body []byte, explicitSession string, bypass bool, models components.ModelSpec, window int, cacheMode string) (result []byte, changedBody bool)
BodyFull is BodyWithModelWindow plus the cache mode ("auto"|"on"|"off", default "auto") controlling cache-aware compaction. "auto" turns on cache-awareness when the backend is a prompt-caching provider or the request already carries cache_control breakpoints; "on" forces it; "off" restores the legacy compact-everything behavior (correct for confirmed non-caching backends).
func BodyWithModel ¶
func BodyWithModel(ctx context.Context, pipe *components.Pipeline, st store.Store, provider bschemas.ModelProvider, body []byte, explicitSession string, bypass bool, models components.ModelSpec) ([]byte, bool)
BodyWithModel runs the pipeline over the request body's messages and returns the rewritten body. changed=false means "forward the original unchanged" (no messages array, unparseable, or a re-serialization problem) — always fail open. explicitSession is the host-supplied session id ("" -> content hash). models carries the LLM clients that NeedsModel components may call.
func BodyWithModelWindow ¶
func BodyWithModelWindow(ctx context.Context, pipe *components.Pipeline, st store.Store, provider bschemas.ModelProvider, body []byte, explicitSession string, bypass bool, models components.ModelSpec, window int) ([]byte, bool)
BodyWithModelWindow is BodyWithModel plus the model's resolved context window (max input tokens, 0 = unknown) so fraction-based Trigger thresholds can scale with the model. Hosts that resolve the window (the proxy, via internal/modelinfo) call this; window=0 reproduces the pre-D3 behavior exactly.
Types ¶
This section is empty.