Repository navigation
Description
Context
Agent definitions toggle three capabilities independently: repository code read (enforced by the workspace in issue 7 — no source is mounted when off), web browsing/fetch, and the ProPR MCP. Telling the model "do not browse" in the prompt is not enforcement. This issue adds an explicit, per-run toolPolicy to AgentTaskOptions and makes the Claude and Codex launchers enforce it with their native CLI switches. Issue 9 supplies the run-scoped ProPR MCP credential that this policy carries.
Scope decision for v1 (documented): enforcement is implemented for the runtimes that support it natively — Claude Code (--disallowedTools, --mcp-config) and Codex (-c tools.web_search=…, -c mcp_servers.*). For Antigravity/OpenCode/Vibe, web=false is applied through the prompt only and the UI shows "best effort" for those agents; propr_mcp is already rejected for them by issue 4.
Requirements
- Extend
AgentTaskOptionsinpackages/core/src/agents/types.ts:AbsenttoolPolicy?: { allowWeb: boolean; mcpServers?: Array<{ name: string; url: string; bearerTokenEnv: string; bearerToken: string }> }
toolPolicy= today's behavior (every existing caller is unaffected). - New
packages/core/src/agents/agentToolPolicy.tswith pure builders:claudeToolPolicyArgs(policy)→{ cliArgs: string[]; env: Record<string,string> }: when!allowWebadd--disallowedTools WebFetch WebSearch; for MCP servers add--mcp-config <inline JSON>whoseheaders.AuthorizationusesBearer ${ENV_NAME}expansion, and put the actual token only inenv(so it never appears inps/logged args).codexToolPolicyArgs(policy)→-c tools.web_search=falsewhen web is off; for each MCP server-c mcp_servers.<name>.url="…"and-c mcp_servers.<name>.bearer_token_env_var="<ENV>"; token inenv.promptOnlyToolPolicyNotice(policy)for other runtimes.
- Wire the builders into
ClaudeAgent.executeTask/buildDockerArgsandCodexAgent.executeTask/codexDockerArgsBuilder: CLI args appended to the agent command; env passed with-e NAME(value viaextraEnvVars) — never-e NAME=valuein args that get logged. - Replace the stub
src/jobs/agentRuns/toolPolicy.tsfrom issue 7 with the real mapping: report phase →allowWeb = capabilities.includes('web'), MCP only ifpropr_mcpenabled and a grant was issued (issue 9 passes it in); action phase → MCP always on, web follows the definition. - Redaction: add the bearer env var names to the secret-redaction patterns so a token echoed by the agent is stripped from logs/LLM logs (
redactSecretsalready handlesBearer …; add a test proving it). - Tests
test/agentToolPolicy.test.ts.
Implementation Specification
- Builders are pure and unit-tested; agent integration changes are a few lines each.
- The MCP name is fixed to
proprso prompts can say "theproprMCP server". - Never write the token to a file in the worktree (worktrees are inspectable by the agent and might be retained by push-salvage on other job types).
Acceptance Criteria
- With
toolPolicy: { allowWeb: false }, the Claude command line contains--disallowedTools WebFetch WebSearch; Codex contains-c tools.web_search=false. - With an MCP server, neither argument list contains the token value; the env map does.
- Existing agent tests pass unchanged (no
toolPolicy→ identical args). -
redactSecrets('Authorization: Bearer abc.def')removes the token.
Created by ProPR AI Planner
Activity
propr-dev commentedon Oct 6, 2026
Suggested Implementation:
Implementation Approach
Enforcement belongs in the launcher, not the prompt. We add one optional field (
toolPolicy) to the agent task contract and two pure argument builders, then make a minimal change in the Claude and Codex launchers to append their output. Keeping the builders pure means the security-relevant part (which flags, where the token goes) is fully unit tested without Docker.Secrets handling: tokens travel only as container environment variables referenced by name (
Bearer ${PROPR_MCP_TOKEN}expansion for Claude,bearer_token_env_varfor Codex). Command-line arguments are logged by the Docker executor and visible inps; environment values passed with-e NAME+ process env are not.Alternative considered: a network firewall to block the web. The optional allowlist firewall exists but is inactive by default and is instance-wide; per-run tool switches are the precise, available control. Firewall integration is a possible later hardening.
File:
packages/core/src/agents/types.tsWhy this file: The agent contract every runtime implements; the new field is optional so all existing callers are unchanged.
File:
packages/core/src/agents/agentToolPolicy.ts(new file)Why this file: Pure translation from policy to CLI flags + env, per runtime. Unit-testable and reviewed in one place.
File:
packages/core/src/agents/impl/ClaudeAgent.ts(andclaudeHelpers.buildDockerArgs)Why this file: Claude Code is one of the two runtimes that enforce the policy natively.
In
buildDockerArgs(packages/core/src/claude/claudeHelpers.ts) acceptextraCliArgs?: string[]and append them after the existing claude flags; for each key ofextraEnvVarsthe executor already emits-e KEYwith the value from the process environment — verify that path does not inlineKEY=value; if it does, change it to-e KEYplusenvon spawn for these keys.File:
packages/core/src/agents/impl/CodexAgent.ts(andcodexDockerArgsBuilder)For Antigravity, OpenCode and Vibe: prepend
promptOnlyToolPolicyNotice(options.toolPolicy)to the prompt (one line each in theirexecuteTask).File:
src/jobs/agentRuns/toolPolicy.tsWhy this file: Maps definition capabilities + phase to a concrete policy (replaces the issue-7 stub).
File:
test/agentToolPolicy.test.ts(new file)Why this file: Proves enforcement flags and that tokens never reach argv.
propr-dev commentedon Oct 6, 2026
🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
claudeclaude-opus-5-52807/claude-opus-5-5-agents-v1-8-17-capability-20261006-1831-y1f2800-epic-agents-v1-y7tissue-2807-20261006-1831-claude-opus-5-5-y1f🔍 Track Task Execution
I implemented per-run tool policy enforcement for issue #2807. Claude…
I implemented per-run tool policy enforcement for issue #2807. Claude…