Documentation
¶
Overview ¶
Package guardrail wraps tool output in untrusted-data sentinels and defangs known prompt-injection markers (role tags, "ignore previous instructions" phrasings, fenced system blocks).
Defense in depth, not a guarantee. Consumers feed every untrusted tool result through WrapToolOutput before appending it to the LLM message history.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var TrustedTools = map[string]bool{ "load_skill": true, "load_reference": true, }
TrustedTools is a default whitelist of tool names whose output is considered author-controlled and therefore exempt from wrapping. Consult and delegation results are deliberately absent: they contain model output or selected external data and must cross back as untrusted data.
Functions ¶
func DefangInjection ¶
DefangInjection inserts a zero-width space into known injection markers so they no longer parse as control tokens.
func ShouldWrap ¶
ShouldWrap returns true when the named tool's output should be wrapped. Pass nil for `trusted` to use the package-level TrustedTools whitelist.
func WrapToolOutput ¶
WrapToolOutput applies the full guardrail (defang + sentinel wrapping + policy header) to a tool result. callID disambiguates concurrent calls in the same turn; pass "" if none is available.
Types ¶
This section is empty.