feat(plugins): add plugin system with guardrail phases, streaming hooks and route strategies - #885
Draft
SantiagoDePolonia wants to merge 4 commits into
Draft
feat(plugins): add plugin system with guardrail phases, streaming hooks and route strategies#885SantiagoDePolonia wants to merge 4 commits into
SantiagoDePolonia wants to merge 4 commits into
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks 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 |
… refreshes, and close plugins on shutdown
SantiagoDePolonia
force-pushed
the
feat/guardrails
branch
from
September 4, 2026 14:39
65f63b7 to
826b176
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a plugin system and rebuilds guardrails on top of it. Guardrail definitions become plugin instances, workflows gain response and stream phases next to the prompt phase, and virtual models can delegate routing to a plugin.
Design:
docs/adr/0012-plugin-system.md, spec indocs/dev/2026-09-03_plugins-and-guardrails-spec.md(status header lists deviations).User-visible changes
pluginapi/(stdlib-only):Plugin+ optionalPromptHook,ResponseHook,StreamHook,RouteStrategy;ExchangewithPrompt,Completion,StreamState,Headers,Values; decisionsallow | block | respond | warn.system_prompt,llm_based_altering(now also on responses),string_replace(multi-line rules, literal/regex, replace/block/respond/warn, streams),header_edit,llm_judge(LLM as judge for prompts and responses),cheapest_healthy(route strategy example).fail_modeandtimeout_ms;GET /admin/guardrails/typesexposesphases,source,mutates.steps[].phase(prompt | response | stream); v1guardrailspayloads still load.GET /admin/workflows/guardrailsnow returns objects{name, type, phases, summary}instead of strings.plugins.search_paths/plugins.load[](sha256 pins) load.sofiles;gomodel plugin buildandgomodel plugin inspect;Dockerfile.plugins; example atexamples/plugins/keywordblock.strategy: pluginwithstrategy_pluginandstrategy_config, validated against the plugin's route fields.GET /admin/plugins.docs/advanced/plugins.mdx(new), guardrails, workflows, admin endpoints, CLI, virtual models.Known gaps (documented in ADR-0012 §10)
requestandcompletehooks are in the contract but not called yet.Headers.Upstreamis not forwarded;Host.Historyis unavailable; route strategies do not receive the prompt.Closed on refresh.Verification
go testacross./cmd ./config ./ext ./internal ./run ./pluginapiandgo test -tags=e2e ./tests/e2e/...(includes loading a real.so).checkclean.