Overview
Bifrost v1.4.x introduces a new plugin interface for HTTP transport layer interception. This guide helps you migrate existing plugins from the v1.3.xTransportInterceptor pattern to the v1.4.x HTTPTransportPreHook and HTTPTransportPostHook pattern.
If your plugin doesn’t use
TransportInterceptor, no migration is needed. The PreLLMHook, PostLLMHook, Init, GetName, and Cleanup functions remain unchanged.What Changed?
The HTTP transport interception mechanism changed from a simple function that receives and returns headers/body to a dual-hook pattern that works with both native.so plugins and WASM plugins.
Key Differences
Why the Change?
The new dual-hook pattern provides:- WASM plugin support - Serializable types work across WASM boundary
- Response interception - Post-hook can modify responses before returning to client
- Simpler API - No middleware wrapper, direct function call
- Better testability - No fasthttp dependency in plugin tests
- Full context access - BifrostContext available for sharing data between hooks
- Custom response short-circuits - Return a full response to short-circuit
Migration Steps
Step 1: Update Imports
Remove thefasthttp import if present:
Step 2: Replace the Function
Before (v1.3.x):Step 3: Update Body Modification Logic
In v1.3.x, you received the body as amap[string]any. In v1.4.x, you work with req.Body bytes:
Before (v1.3.x):
Common Migration Patterns
Adding Headers
v1.3.x:Reading Headers
v1.3.x:Conditional Processing
v1.3.x:Error Handling / Short-Circuit
v1.3.x:Accessing Request Method and Path
v1.3.x:Testing Your Migration
-
Build your updated plugin:
-
Update Bifrost to v1.4.x:
-
Test with a simple request:
-
Verify logs show both hooks being called:
Troubleshooting
Plugin fails to load after migration
Error:plugin: symbol TransportInterceptor not found
This error occurs if Bifrost v1.4.x is looking for the old function. Make sure:
- You’ve updated to
HTTPTransportPreHookandHTTPTransportPostHook - The function signatures match exactly:
func HTTPTransportPreHook(ctx *schemas.BifrostContext, req *schemas.HTTPRequest) (*schemas.HTTPResponse, error)func HTTPTransportPostHook(ctx *schemas.BifrostContext, req *schemas.HTTPRequest, resp *schemas.HTTPResponse) error
- You’ve rebuilt the plugin with the correct core version
Body modification not working
Make sure you’re assigning back toreq.Body in the pre-hook:
Response modification not working
Make sure you’re modifyingresp in the post-hook:
Headers not being set
Make sure you’re modifyingreq.Headers or resp.Headers directly:
Context values not available in post-hook
Make sure you’re using the correct context key type:Streaming Chunk Hook (v1.4.x)
Bifrost v1.4.x introduces a new hook for intercepting streaming response chunks:HTTPTransportStreamChunkHook
This hook is called for each chunk during streaming responses, allowing plugins to modify or filter chunks before they’re sent to the client.HTTPTransportPostHook:
HTTPTransportPostHook is not called for streaming responses. Use HTTPTransportStreamChunkHook instead to intercept streaming data.Migration for Existing Plugins
If your plugin implementsHTTPTransportPostHook and you want to also handle streaming responses, add the new hook:
Need Help?
- Discord Community: Join our Discord
- GitHub Issues: Report bugs or request features
- Writing Plugins Guide: Full plugin documentation

