#13042: feat(security): add guard model for prompt injection sanitization
docs
channel: msteams
gateway
size: M
Cluster:
Security Enhancements and Guardrails
Implements a lightweight guard model pipeline to sanitize external untrusted content (emails, web, tools) before it reaches the main agent context.
- Adds `security.guardModel` configuration
- Implements core sanitization logic in `src/security/guard-model.ts`
- Provides true upstream isolation for dirty content
- Aligns with security roadmaps for Agentic AI safety
References Discussion #11130
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adds a new “guard model” sanitization pipeline intended to pre-process untrusted external content before it is passed to the primary agent.
Changes include:
- A new `GuardModelConfig` shape (Zod + inferred type) and a new `guardModel` field on `AgentDefaultsConfig`.
- A new `sanitizeWithGuardModel` implementation under `src/security/guard-model.ts` plus unit tests.
- Documentation describing the concept and configuration.
The main integration point is the agent defaults schema/type plumbing, which makes the new config available across the existing config system.
<h3>Confidence Score: 3/5</h3>
- This PR is close, but has a definite schema import/export issue that will break config parsing until fixed.
- Most additions are isolated (new module + tests + docs), but `AgentDefaultsSchema` currently imports `GuardModelConfigSchema` from a module that doesn’t export it, which will cause a runtime/build failure when the schema is loaded. There’s also an unused import in the new guard-model module that may fail CI depending on TS/ESLint settings.
- src/config/zod-schema.agent-defaults.ts, src/security/guard-model.ts
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#8086: feat(security): Add prompt injection guard rail
by bobbythelobster · 2026-02-03
75.3%
#10357: Guardian: add validation script + docs
by DD-Ching · 2026-02-06
74.5%
#6095: feat(gateway): support modular guardrails extensions for securing a...
by Reapor-Yurnero · 2026-02-01
73.6%
#14640: feat(agents): support per-agent temperature and maxTokens in agents...
by lailoo · 2026-02-12
73.5%
#14136: feat: add agent collapse safeguards and fix TUI display on abort
by liangweigain-create · 2026-02-11
72.4%
#11562: Fix #10883: Enforce subagent model configuration
by divol89 · 2026-02-08
71.3%
#7983: feat(security): add secure coding guidelines to system prompt
by TGambit65 · 2026-02-03
71.1%
#13376: fix: pass model directly to agent for sub-agent runs
by jrbobbyhansen-pixel · 2026-02-10
70.7%
#7851: feat: secure sandbox defaults for new installs
by ichbinlucaskim · 2026-02-03
70.6%
#9583: fix(models): allow models in agents.defaults.models even if not in ...
by hotzen100 · 2026-02-05
70.6%