microsoft / microsoft/agent-governance-toolkit
claude-code: allow policies to configure the hardcoded guard context preamble
- Dominant language
- Python
- Stars
- 6.3k
- Forks
- 1.1k
- Avg merge
- 5d 11h
- Merged PRs (30d)
- 142
Description
## Problem
The ten-line production guard preamble (`PRODUCTION_GUARD_CONTEXT` in `agent-governance-claude-code/lib/policy.mjs`) is hardcoded and prepended to `additionalContext` unconditionally. It is injected into the session at SessionStart and again on **every** UserPromptSubmit, and no policy file — bundled or user — can trim or replace it. Long-running sessions pay a repeated context cost, and the fixed wording can interact awkwardly with instructions from other installed plugins.
## Proposal
An optional `guardContext` policy key:
- **present** → replaces the built-in preamble,
- **empty array** → suppresses it entirely,
- **absent** → behavior byte-for-byte identical to today (no change for existing users).
The prompt defense grade already reflects whatever context is configured, so a slimmed preamble is surfaced honestly in `agt_policy_status` rather than hidden.
## Offer
This is implemented with tests (replacement, suppression, unchanged default) on https://github.com/talosrobotics/agent-governance-toolkit/tree/pr/guard-context — happy to open the PR if the approach is acceptable.
Raising it as an issue first rather than a PR because `AGENTS.md` asks contributors to check with maintainers before security model changes, and making the guard prompt configurable qualifies.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Contributor guide
Research direction
Start in agent-governance-claude-code/lib/policy.mjs and trace how PRODUCTION_GUARD_CONTEXT is added to additionalContext during SessionStart and UserPromptSubmit. Review the referenced guard-context implementation and its replacement, suppression, and unchanged-default tests, then verify that policy status still reports the configured prompt defense grade and existing behavior remains byte-for-byte identical when guardContext is absent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100