Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions promptbook/prompts.json
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,26 @@
],
"formatNotes": "All three. Point the tool at the gateway route config, provider clients, prompt templates, Azure OpenAI Bicep or Terraform, the eval job, and the test folder. Copilot: llm-rollout path instructions plus those files in agent mode (or save the prompt as `.github/prompts/roll-out-llm-model-or-prompt-change.prompt.md`). Claude Code: the llm-model-prompt-rollout-guardrails skill plus those files. Codex: the AGENTS.md LLM rollouts section, then the diff. Leave golden-set scoring, routing order, budgets, tracing names, and re-indexing to their own skills.",
"body": "Task: Put the LLM route or gateway I specify on versioned, staged releases so that a model version upgrade, provider switch, or prompt and parameter change ships as one pinned bundle through offline eval, shadow, and a sticky canary, with criteria committed up front and a tested one-step rollback. Finish with a minimal diff, config, and tests.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Service: {{APP_NAME}} at {{APP_PATH}}\n- Stack: {{STACK}} (Spring Boot version; Spring AI | LangChain4j | hand-rolled HTTP clients; config source: application.yaml | App Configuration | database)\n- Routes and providers: {{ROUTES}} (route names, Azure OpenAI deployments, Bedrock, OpenAI-compatible routers; where prompts live today)\n- Change to ship: {{CHANGE}} (new model version or family, provider switch, prompt edit, parameter or schema change, forced retirement)\n- Deployment config: {{IAC}} (Bicep or Terraform files declaring Azure OpenAI deployments; versionUpgradeOption today)\n- Eval gate: {{EVAL}} (existing golden-set job and command, judge setup)\n- Guard metrics source: {{METRICS}} (usage store, OpenTelemetry backend, feedback signal)\n- Risky routes: {{SIDE_EFFECTS}} (routes or tools with irreversible actions)\n\nRequirements:\n\n1. Inventory\n - Table: route | provider deployment | model and version requested | model returned | upgrade policy | retirement date | prompt location and versioning | parameters source | bundle ID today? | rollback path today\n - Flag floating aliases, unset or auto-upgrading versions on production routes, prompts edited at runtime, missing version IDs in telemetry, and any retirement within 90 days\n\n2. Release bundle\n - Define an immutable bundle per route: deployment, dated model version, prompt template IDs and hashes, decoding parameters, tool and output schema versions, retrieval settings by reference, guardrail policy versions\n - Route config points at a bundle ID; resolution happens at request time; unknown IDs fail startup\n - Bundle ID in response metadata, `llm.gateway.bundle` span attribute, usage rows, eval runs, and cache keys\n\n3. Model pinning and retirement\n - Set `versionUpgradeOption` explicitly in {{IAC}} for every Azure OpenAI deployment and explain the choice; note PTU deployments never auto-upgrade\n - Use dated snapshot IDs for other providers; emit a mismatch metric when the returned model differs from the bundle\n - Add a checked-in model inventory and a scheduled job that opens an issue or fails at 90 days to retirement without a candidate bundle and at 30 days without a completed canary\n\n4. Prompt registry\n - Move templates to versioned files (ID, version, owner, intended model, variables, schema reference); load by ID; log the content hash; no runtime edits\n - Render tests with fixture variables, checking required sections and that untrusted input stays delimited\n\n5. Stages and criteria\n - Rollout plan file per change: stages (offline eval, shadow, canary steps, GA), and per stage the metric, comparison to the control cohort, threshold, window, minimum sample, segments, and action (hold, halt, roll back)\n - Offline: wire the candidate bundle into {{EVAL}}\n - Shadow: sampled and stratified mirror, user sees only the current answer, candidate tools stubbed or isolated, separate budget and quota, dropped first under load, content handled under the same redaction and retention rules\n - Canary: sticky assignment by stable hash of tenant or user, conversation pinned to its bundle, {{SIDE_EFFECTS}} excluded or approval-gated, stepwise ramp\n - Automatic rollback on severe or repeated breach; insufficient sample means hold\n\n6. Rollback\n - One config change returns the route to the previous bundle without redeploy; propagate to all replicas within a minute\n - Run it once during shadow or early canary and record the result\n\n7. Tests\n - Bundle resolution and startup failure on unknown IDs; sticky cohorts stable across replicas and restarts and when the percentage changes; shadow never executes real tools and never affects user latency or errors; model mismatch metric fires on a stubbed different `model`; rollback switches new requests without restart; retirement job fails on a fixture deployment near retirement\n\n8. Verification\n - Updated inventory table, the bundle and rollout plan for {{CHANGE}}, a sample shadow comparison report (scores and IDs only, no content), and the rollback drill result\n\nConstraints:\n- Minimal diff. Reuse the existing gateway routing, config source, eval job, and telemetry; no new platform.\n- Never run candidate side effects in shadow. Never loosen eval thresholds or delete tests to pass a stage.\n- Leave golden-set scoring, routing and fallback order, budgets and prices, tracing names, and re-indexing to their existing skills; call their hooks.\n- Copilot, Claude Code, and Codex: concrete diffs, the inventory table, the rollout plan file, and a checklist. Do not paste this prompt into AGENTS.md.\n\nOutput format:\n1. Inventory table with the gaps found\n2. Bundle definition, route config, and IaC diff (upgrade policy included)\n3. Prompt registry layout and loader diff\n4. Rollout plan file, shadow and canary wiring, and rollback switch\n5. Tests added and what each asserts\n\nStart from {{APP_PATH}}. Pin versions and stop unscheduled upgrades first, then introduce bundles and the registry, then shadow, canary, and the rollback drill.\n"
},
{
"id": "gate-llm-agent-tool-calls",
"title": "Gate LLM Agent Tool Calls with Authorization and Approvals",
"whenToUse": "Harden a tool-calling agent or assistant before real users — tool inventory, registry with risk classes and closed schemas, narrow tools in place of generic ones, per-user filtering, user identity from context, on-behalf-of downstream calls, pending actions with argument-bound single-use approvals, idempotency keys, loop caps, tool spans, and tests for authz, approval tampering, injection, and caps.",
"tools": [
"copilot",
"claude-code",
"codex"
],
"tags": [
"llm",
"agents",
"security",
"authorization",
"spring-boot",
"mcp"
],
"formatNotes": "All three. Point the tool at the agent loop, tool classes or MCP client config, auth config, downstream clients, and the test folder. Copilot: agent-tools path instructions plus those files in agent mode (or save the prompt as `.github/prompts/gate-llm-agent-tool-calls.prompt.md`). Claude Code: the llm-agent-tool-execution-guardrails skill plus those files. Codex: the AGENTS.md Agent tools section, then the diff. Leave injection text handling, output schemas, idempotency storage, tracing names, and budgets to their own skills.",
"body": "Task: Put the tool-calling agent or assistant I specify behind execution guardrails so that the model can only call narrow, authorized tools as the signed-in user, and no irreversible write runs without an approval bound to its exact arguments. Finish with a minimal diff, config, and tests.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Service: {{APP_NAME}} at {{APP_PATH}}\n- Stack: {{STACK}} (Spring Boot version; Spring AI 2.x ChatClient | LangChain4j AiServices | hand-rolled loop; MCP client or server?)\n- Tools today: {{TOOLS}} (where they are defined; local beans, MCP servers, HTTP APIs)\n- Identity: {{IDENTITY}} (Entra ID or other OIDC; how user, tenant, and scopes reach the service; on-behalf-of available?)\n- High-impact actions: {{ACTIONS}} (sends, payments, deletes, access changes, deployments, limits that need approval)\n- Approval surface: {{APPROVAL_UI}} (web UI, chat card, Teams or Slack button, API client)\n- Downstream idempotency: {{IDEMPOTENCY}} (which APIs accept an Idempotency-Key)\n- Limits: {{LIMITS}} (max turns, tool calls, time, tokens per request; rate limits per user)\n\nRequirements:\n\n1. Inventory\n - Table: tool | source (bean, MCP server, API) | what it does | state change? | reversible? | credential used | tenant and user source | argument schema (open or closed) | approval today | idempotent? | timeout\n - Flag generic tools (shell, SQL, arbitrary URL, file path), service-account credentials, identity taken from model arguments, writes without approval, open schemas, and missing timeouts\n\n2. Tool registry\n - One registry declaring each tool with risk class (read, sensitive-read, write-reversible, write-irreversible, open-world), closed argument schema (additionalProperties false, enums, patterns, size limits), required scopes, tenant field, timeout, idempotency behavior, and approval rule with a confirmation template\n - Replace generic tools with narrow ones for the cases actually used\n - Filter the tool list per route and per user scopes before each model request\n - For MCP servers: treat annotations as hints, map each remote tool to a registry risk class (missing means destructive and open-world), and pin full tool definitions by hash with an alert on change\n\n3. Identity and authorization\n - Pass user, tenant, and scopes out of band (Spring AI ToolContext or the framework equivalent); ignore or reject model-supplied identity fields\n - Call downstream APIs as the user (on-behalf-of) or with a policy check that uses the user's identity\n - Re-check ownership of every ID in arguments; trim results to what the user may see; no secrets in results\n\n4. Approval protocol\n - Write-irreversible calls (and {{ACTIONS}} over the agreed limits) create a pending action with ID, canonical arguments, argument hash, user, tenant, conversation, and short expiry, and execute nothing\n - Render the confirmation from canonical arguments in code via {{APPROVAL_UI}}\n - Separate authenticated approve and decline endpoints: same user, unexpired, unused, hash match; execute once; record the audit entry\n - Tell the model clearly when an action is pending, declined, or expired\n - Put the gate in code inside the tool loop (Spring AI advisor in the loop, or a user-driven loop with ToolCallingManager; LangChain4j tool executor wrapper), never only in the system prompt\n\n5. Side-effect safety\n - Idempotency key per write from the pending action ID or tool call ID, forwarded to {{IDEMPOTENCY}}\n - No automatic retry after ambiguous write failures; report unknown outcome\n - Dry-run mode for every write tool; drafts or staged changes where the domain allows\n - Output of open-world and sensitive-read tools is untrusted for the next turn and cannot trigger a write without approval\n\n6. Limits\n - Enforce {{LIMITS}}: turns, total tool calls, per-tool calls, wall-clock time, tokens; stop with a partial result on a cap\n - Repeat detection for the same tool and arguments; writes run serially; per-user and per-tenant rate limits on write tools\n\n7. Observability\n - Span per tool execution with tool name, risk class, decision (executed, pending_approval, denied_authz, denied_policy, cap_reached), approval ID, duration; no arguments or results by default\n - Metrics and alerts for denied and pending spikes, approvals by outcome, and cap hits\n\n8. Tests\n - Registry completeness; per-user filtering; cross-tenant and forged-identity calls refused; pending action executes nothing; approval executes once; replayed, expired, other-user, and argument-changed approvals refused; idempotent retry hits the downstream stub once; injected instruction in a retrieved document yields at most a pending action with real arguments; caps stop a looping stub model\n\n9. Verification\n - Updated inventory table, the registry diff, one sample pending action and its confirmation text, and the test run summary\n\nConstraints:\n- Minimal diff. Reuse the existing auth, HTTP clients, idempotency store, and telemetry; no new agent framework.\n- Never weaken approval to make a test pass; never use real recipients, payment details, or customer data in fixtures.\n- Leave prompt-injection text handling, output schema validation, idempotency storage design, tracing names, and token budgets to their existing skills; call their hooks.\n- Copilot, Claude Code, and Codex: concrete diffs, the inventory table, and a checklist. Do not paste this prompt into AGENTS.md.\n\nOutput format:\n1. Inventory table with the gaps found\n2. Tool registry and filtering diff\n3. Identity and authorization changes\n4. Approval protocol, endpoints, and loop gate diff\n5. Idempotency, limits, observability, and tests added\n\nStart from {{APP_PATH}}. Remove generic tools and model-supplied identity first, then gate irreversible writes behind approvals, then idempotency, limits, and tests.\n"
}
]
}
Loading
Loading