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 @@ -1162,6 +1162,26 @@
],
"formatNotes": "All three. Point the tool at the provider clients, routing and retry code, streaming handler, Observation or tracer config, logback config, Collector config, and the test folder. Copilot: llm-tracing path instructions plus those files in agent mode (or save the prompt as `.github/prompts/add-llm-tracing-and-genai-metrics.prompt.md`). Claude Code: the llm-tracing-observability-guardrails skill plus those files. Codex: the AGENTS.md LLM tracing section, then the diff. Leave budgets, Collector cluster setup, redaction rules, streaming deadlines, and eval scoring to their own skills.",
"body": "Task: Add or fix OpenTelemetry tracing and metrics for the LLM service or gateway I specify so that one inbound request produces one readable trace with model attempts, retrieval, tools, and guardrail checks, using the GenAI semantic conventions, with no prompt or completion text in telemetry by default. 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; WebFlux or MVC; virtual threads?)\n- Instrumentation today: {{INSTRUMENTATION}} (OpenTelemetry Java agent | Micrometer Tracing with OTel bridge | vendor SDK | none)\n- Providers and routes: {{PROVIDERS}} (Azure OpenAI, OpenAI-compatible routers, Bedrock, others; retry and fallback logic location)\n- Backend: {{BACKEND}} (OTel Collector then Datadog | Azure Monitor | Tempo/Grafana | other)\n- Conventions version: {{SEMCONV_VERSION}} (pin one; note the instrumentation library's GenAI stability setting if it has one)\n- Data rules: {{DATA_RULES}} (what may never leave the service; telemetry retention; redaction hook to reuse)\n- Async paths: {{ASYNC}} (streaming/SSE, reactive, @Async, queues)\n\nRequirements:\n\n1. Inventory\n - Table: operation (inbound endpoint, chat, embeddings, retrieval, tool, agent loop, guardrail) | span today? | parent correct? | attributes today | content captured? | metrics today | labels | propagation across async?\n - Flag new traces per upstream call, missing retry/fallback attempts, prompts or completions in spans or logs, user/conversation IDs as metric labels, estimated usage where the provider returned real usage, and vendor-specific names where GenAI names exist\n\n2. Span tree\n - SERVER span for the inbound request; CLIENT span per model attempt named `{operation} {model}`; retrieval span; `execute_tool {tool}` INTERNAL spans; `invoke_agent {agent}` around agent loops; INTERNAL spans or events for guardrail checks\n - Attempt number and routing or fallback reason on each attempt span; span status ERROR with `error.type` only for real failures; refusals recorded as finish reasons\n\n3. Attributes\n - GenAI attributes from {{SEMCONV_VERSION}}: operation name, provider name, request and response model, request parameters actually sent, response ID, finish reasons, input and output token usage from the provider usage block, tool name and call ID, agent name, conversation ID (span only), server address and port\n - All GenAI names in one constants class; gateway-specific facts (route, tenant, deployment, cache hit, budget decision, fallback reason) under `llm.gateway.*`\n - Mark estimated usage explicitly when a stream ends without a usage block\n\n4. Content capture\n - Off by default for input and output messages, system instructions, tool definitions, tool arguments and results, and retrieved text, in spans, events, and logs\n - Disable framework prompt and completion logging and HTTP wire logging; record shape instead (message count, token counts, chunk IDs and scores)\n - Optional opt-in: named flag per environment or tenant, time-boxed, passed through the existing redaction hook, preferably exported to a separate store referenced by ID\n\n5. Metrics\n - GenAI token usage histogram with token type, and the duration histograms the pinned version defines (per-operation in newer versions); time to first token and time per output token for streaming\n - Labels limited to operation, provider, request and response model, route, outcome or `error.type`, token type; bounded tenant only if small\n - If using Micrometer Observation, map exported names to the conventions with an observation convention class\n\n6. Propagation\n - W3C trace context continued from the caller and sent to providers; preserved across {{ASYNC}}; injected into message headers for queues\n - Baggage restricted to non-sensitive low-cardinality keys; untrusted inbound baggage stripped before provider calls\n - `trace_id` and `span_id` in log MDC\n\n7. Sampling and export\n - SDK head sampling plus Collector tail sampling keeping errors, fallbacks, guardrail blocks, and requests above the latency SLO\n - OTLP to the Collector; Collector attribute-delete processor for content keys as a backstop; resource attributes for service name, version, environment, namespace, and pod\n - Exporter failure never fails a request; bounded queue with a dropped-spans counter\n\n8. Tests\n - In-memory span exporter with a stubbed provider: span tree per request including retry and fallback attempts; required attributes; no content, keys, or Authorization headers anywhere; opt-in path emits redacted content only when enabled; inbound traceparent continued and outbound carries it; context survives streaming and async paths; forbidden metric labels absent\n - A test that pins the attribute names in the constants class\n\n9. Verification\n - One example trace (attribute keys only, no content) before and after, the updated inventory table, and the dashboard or monitor queries that need renaming\n\nConstraints:\n- Minimal diff. Reuse the existing tracer, Observation registry, and Collector; no new vendor SDK.\n- Do not loosen redaction or delete tests to make CI pass. Do not put real prompts or customer data in fixtures.\n- Leave budgets and price tables, Collector cluster setup, log formatting, redaction rules, streaming deadlines, and eval scoring 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. Span tree and attribute diff (constants class included)\n3. Content capture settings and redaction hook wiring\n4. Metrics, propagation, sampling, and Collector config diff\n5. Tests added and what each asserts\n\nStart from {{APP_PATH}}. Remove content leaks first, then fix trace continuity and per-attempt spans, then names, metrics, and sampling.\n"
},
{
"id": "roll-out-llm-model-or-prompt-change",
"title": "Roll Out an LLM Model or Prompt Change Safely",
"whenToUse": "Ship a model version upgrade, provider switch, forced retirement migration, or prompt and parameter change on an LLM route — inventory of versions and retirement dates, immutable release bundle per route, explicit Azure OpenAI versionUpgradeOption in IaC, model mismatch alarm, prompt registry, rollout plan with pre-committed criteria, side-effect-free shadow, sticky canary ramp, automatic rollback, and a rollback drill with tests.",
"tools": [
"copilot",
"claude-code",
"codex"
],
"tags": [
"llm",
"release",
"canary",
"azure-openai",
"spring-boot",
"evaluation"
],
"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"
}
]
}
Loading
Loading