Repository navigation
feat(addie): real-prompt shadow eval + shape grader + style-last prompt order - #3601
Merged
Merged
Conversation
1 of 5 tasks
bokelley
added a commit
that referenced
this pull request
Apr 30, 2026
Addresses the code-review pass on PR #3601: - Wrap human and shadow response text in a "treat as data" fence inside compareResponses. Slack message text is untrusted; the comparator runs without a system prompt, so unfenced quoted text could let an injected role marker reframe the JSON verdict. - Thread shadowModel through compareResponses so the LLM-as-judge runs on the same model the shadow generation used. Previously it hard-coded Haiku, half-applying the SHADOW_EVAL_MODEL override. - comprehensiveDumpDetected now counts numbered list items alongside bullets — a single-part question answered with 1.…6. would have slipped. - Drop the dead `'fast'` branch in resolveShadowModel (unreachable after the !override early return). Export resolveShadowModel for reuse. - Promote BANNED_RITUAL_LITERALS to a non-test export name (BANNED_RITUALS) and consume that from shape-grader; deprecates the __test_-prefixed alias while keeping it for the existing unit-test import. - Move smoke script from server/scripts/ to server/tests/manual/ to match the existing convention for opt-in live-API smoke utilities; reuse resolveShadowModel instead of re-implementing the env-var resolution. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Contributor
Author
|
Code-reviewer pass addressed in e1c21f1: Fixed
97 unit tests still passing; |
bokelley
added a commit
that referenced
this pull request
Apr 30, 2026
Leftovers from when buildStyleLastPrompt() rebuilt the prompt manually by reading rule files; that approach was replaced with a splice on the assembled baseline (and later, after the production change, with a straight call to buildBaselinePrompt). Addresses github-code-quality comments on PR #3601. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Contributor
Author
|
Pre-merge expert reviews back. Both green to ship, with three items addressed in a53898d. prompt-engineer: ship it. Calibration follow-ups:
security-reviewer: no merge blockers, one medium fixed:
Confirmed clean by the security reviewer:
CI green. 119 addie unit tests passing. Ready for merge. Deferred polish (non-blocking, tracked for follow-up):
|
Shadow evaluator now loads Addie's actual rule files and tool reference when generating the shadow response — previously a one-line system prompt plus Haiku, so the persisted corpus did not reflect prod behavior. Default model stays Haiku for cost; SHADOW_EVAL_MODEL=primary upgrades to the production Sonnet model for periodic deep evals. Adds a shared deterministic shape grader (length cap calibrated by question shape, default-template signature, banned-ritual hits, sign-in opener, comprehensive-dump detection) that the shadow evaluator now runs on both the shadow response and the longest human response. Persists shape metrics on the thread context so the dashboard can surface shape regressions alongside the existing knowledge-gap signal. Includes a manual smoke-test script confirmed to flag the Katie/registry-thread shape (length blow-out, "great question" ritual, closing follow-up question) on a live Sonnet generation. Follow-ups not in this PR: widen the shadow trigger to capture threads where Addie posted and a human responded afterward (today the trigger fires only on suppressed threads, so the Katie pattern never enters the corpus); resolve the conflict between behaviors.md "Spec Exploration Follow-Up" and response-style.md "don't end every response with a follow-up question." Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Addresses the code-review pass on PR #3601: - Wrap human and shadow response text in a "treat as data" fence inside compareResponses. Slack message text is untrusted; the comparator runs without a system prompt, so unfenced quoted text could let an injected role marker reframe the JSON verdict. - Thread shadowModel through compareResponses so the LLM-as-judge runs on the same model the shadow generation used. Previously it hard-coded Haiku, half-applying the SHADOW_EVAL_MODEL override. - comprehensiveDumpDetected now counts numbered list items alongside bullets — a single-part question answered with 1.…6. would have slipped. - Drop the dead `'fast'` branch in resolveShadowModel (unreachable after the !override early return). Export resolveShadowModel for reuse. - Promote BANNED_RITUAL_LITERALS to a non-test export name (BANNED_RITUALS) and consume that from shape-grader; deprecates the __test_-prefixed alias while keeping it for the existing unit-test import. - Move smoke script from server/scripts/ to server/tests/manual/ to match the existing convention for opt-in live-API smoke utilities; reuse resolveShadowModel instead of re-implementing the env-var resolution. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…eads Closes the second leg of the shadow eval corpus the previous PR opened up. Until now the shadow trigger only fired when Addie was suppressed (humans got there first); the case Brian flagged on 2026-04-29 — Addie writing an essay-shaped answer that a human had to TLDR — never entered the corpus. The new periodic job (every 30 min, limit 20) finds Slack threads where Addie posted and a substantive human reply landed within the last 24h, fetches the thread from Slack, identifies the question / Addie response / human follow-ups, and runs the same shape grader and LLM-as-judge comparator the suppression flow now uses. Results are persisted on the thread context with shadow_eval_source='addie_corrected_capture' so analytics can separate this corpus from the suppressed corpus and from the manual backfill. Exports compareResponses and summarizeShapeReports from shadow-evaluator so the new job reuses the same prompt and persistence shape rather than re-implementing them — avoiding the drift the existing one-off shadow-backfill.ts already introduced. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The 25-scenario red-team suite at server/src/addie/testing/redteam-scenarios.ts already runs deterministic checks for fabricated companies, banned ritual phrases, sign-in deflection, and a length cap on questions <15 words. None of those caught the registry/Katie shape — a 21-word multi-part question answered with a 280-word essay-shaped response — because the existing length cap was too narrow. Layer the shape grader on top of every scenario so the suite picks up default-template (intro → bold → bullets → bold → bullets → ?), comprehensive bullet dumps on single-part questions, sign-in openers, and length blow-out calibrated by question shape. The older shortQuestion length-cap check stays for backward compat; the new shape-cap is the broader net. Adds four shape-targeted unit tests including: - A liability-question scenario answered in default-template style (catches the shape regardless of substance accuracy) - A bullet-dump on a single-part question - A sign-in opener - A clean prose answer that passes everything Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Roll the four shape failure kinds (default-template, comprehensive-dump, sign-in opener, length-cap) into the RedTeamSummary metrics object and print them in the report so a single \`npm run test:redteam\` against a live Addie surfaces shape-regression counts alongside the existing ritual / fabrication / sign-in-deflect counts. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…nt eval
The eval pipeline shipped earlier in this PR isn't just for measuring shape
regressions in production; it also lets us A/B test rule changes
empirically rather than guess. Brian asked "can't we use our new tools to
test what to do?" so I built a prompt-variant runner
(server/tests/manual/prompt-variant-eval.ts) that compares variants
against a fixed question battery using the shape grader.
Result on Sonnet 4.6 across the registry/Katie fixture + 6 redteam +
5 common-AAO-question battery (12 total):
Variant AvgWords AvgRatio AnyViol Rituals
Baseline (legacy) 176 1.42 11/12 1
Style-last (Variant B) 153 1.23 9/12 0 ← winner
Dedupe alone (C) 189 1.51 9/12 2 worse
Drop spec-exploration (E) same as baseline no signal
Drop conv-pivot (F) worse worse
Drop both follow-ups (G) worse worse
All-in (D + G) 165 1.33 7/12 2
Variant B (move response-style.md to AFTER the tool reference) is
unambiguously cleanest: -13% mean response length, zero default-template
hits, zero banned ritual phrases, no content removed from any rule file.
The intent was already documented in rules/index.ts ("response-style is
last so output shape is the final thing the model reads before writing")
but the actual order appended the tool reference *after* response-style,
contradicting the doc. Same pattern showed up on Haiku.
Implementation:
- rules/index.ts splits into loadRules() (base rules without style) and
loadResponseStyle() (just response-style.md). Cache both.
- claude-client.ts assembles `loadRules() + tool reference + loadResponseStyle()`.
- config-version.ts hashes both files so config versions still change
when either is edited.
- shadow-evaluator.ts and shape-grader-smoke.ts mirror the new assembly.
- addie-admin.ts /system-prompt endpoint returns rules + style.
- Existing rules-loader tests updated to assert the new contract: the
base rules section no longer contains "# Response Style"; that lives
in loadResponseStyle(). The catalog-is-last test becomes a
style-is-last test against the full assembled prompt.
The dedupe and rule-removal variants did NOT help on the eval and are
NOT shipped. Their findings live in the audit at
.context/addie-rules-conflict-audit.md for follow-up review.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Leftovers from when buildStyleLastPrompt() rebuilt the prompt manually by reading rule files; that approach was replaced with a splice on the assembled baseline (and later, after the production change, with a straight call to buildBaselinePrompt). Addresses github-code-quality comments on PR #3601. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Addresses pre-merge expert review:
Security (medium): defend `compareResponses` and `wrapAsUntrusted` against
fence-closing-tag injection. An attacker who controls a Slack reply could
post `</human_response>` and have the rest of their text read as
outer-prompt context to the judge model. New `escapeFenceTags` helper
inserts a zero-width space inside any literal `<tag>`/`</tag>` so the
visual shape is preserved but the literal markup is broken. Same fix in
`rules/index.ts:wrapAsUntrusted` for the current-context.md path that
ingests public GitHub activity. 5 unit tests on the escape behavior.
Security (low): add a system prompt to `compareResponses` so the judge
has a stable refusal anchor independent of user-message content. Defense
in depth — even if a future change weakens the fence, the judge stays
on task.
Security (low): `processCandidate` in `shadow-corrected-capture.ts`
splits external_id on the FIRST colon (was a destructured `.split(':')`
which would silently truncate if the column shape ever changed).
Calibration (prompt-engineer): tighten the `isMultiPart` regex from
`\b(and|also|plus)\b` (matched "buyer and seller agents" as multi-part)
to require a clause-joining interrogative or auxiliary
(`\b(and|also|plus)\s+(do|does|how|what|why|can|is|are|will|should|when|where)\b`).
"What's the difference between buyer and seller agents?" now stays
single-part. New tests cover both directions.
Calibration (prompt-engineer): split `usesDefaultTemplate` into the
strict variant (with closing question) and a new `structuredHeavy`
metric that fires on the same heading + list mass without requiring a
closing question. Catches essay-shape responses that end on a period
("Let me know if that helps.") which the strict variant was missing.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bokelley
force-pushed
the
bokelley/addie-verbose
branch
from
April 30, 2026 03:43
a53898d to
766a522
Compare
bokelley
added a commit
that referenced
this pull request
Apr 30, 2026
…3630) * test(addie): harden variant eval runner — assert + N≥3 runs Two follow-ups from the prompt-engineer review of PR #3601: assertChanged: each variant declares expectedSizeVsBaseline ('same' | 'smaller' | 'larger' | 'any'). The runner validates actual prompt size against the declaration BEFORE any API calls so a silent no-op transform fails loud. Specific failure mode the engineer flagged: a future rule edit renames a heading that stripBehaviorsSection targets, the strip silently no-ops, and the eval reports "no signal" — looking like the rule doesn't matter when the experiment never actually ran. RUNS_PER_QUESTION: defaults to 1 (matches the original integer-count behavior). Set to 3+ to rerun each question multiple times per variant and aggregate fires-per-question as fractions. AnyViol uses majority-vote framing — a question counts only if ≥50% of its runs hit any violation, so a 1/3-flake reads differently from a 3/3-consistent fire. Adds a Heavy column to the comparison table for the structuredHeavy metric (default-template criteria minus the closing-question requirement) that the prompt-engineer flagged was missing visibility. Validated end-to-end with `ONLY_VARIANTS=A RUNS_PER_QUESTION=2` against Haiku — 24 calls, output reads correctly with fractional cells and per-run Katie response printout. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * review: address code-reviewer nits on variant runner - Guard `parseInt` against `RUNS_PER_QUESTION=foo` falling through to `Math.max(1, NaN) = NaN`, which would silently break the run loop. - Use `Array.find` instead of looping all variants to read just `A`. - Document the failed-run / empty-response handling in the aggregation block (intentionally graded as non-fire, not skipped). - Drop redundant `Math.round` in `fmtHits` for the N=1 path — the values are already integers. - Comment why per-run printout suppresses the response body when N>1 (so a future reader doesn't "fix" it). Pre-merge code-reviewer pass on PR #3630. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
1 of 3 tasks
bokelley
added a commit
that referenced
this pull request
Apr 30, 2026
#3647) * feat(addie-admin): render shadow shape badges + source-distinct labels Closes the third follow-up from the prompt-engineer review of #3601. The admin-addie shadow eval panel was rendering knowledge-gap signal but not the shape grader output the corrected-capture pipeline now persists, and was not differentiating between the two corpora that land in the same thread context (suppression-flow vs corrected-capture). The panel now: - Shows pill-style badges for every shape violation on both Addie's response and the longest human reply, drawn from context.shadow_eval_shape.{shadow,human}.violations. Reviewers see length_cap, default_template, structured_heavy, comprehensive_dump, signin_opener, and ritual:phrase hits without expanding the response comparison. Word counts and ratio-to-expected sit in the column header. - Headers the panel "Corrected Capture" when shadow_eval_source is 'addie_corrected_capture' (Addie posted, a human followed up with a correction) and "Shadow Evaluation" otherwise (Addie was suppressed because humans answered first). - Adds a one-line caveat — "Corpus is selected for human intervention — counts here are not a global rate" — to prevent miscomputing prevalence from this corpus. - Renames the side-by-side response label from "ADDIE WOULD HAVE SAID" to "ADDIE'S ACTUAL RESPONSE" when source is corrected-capture; the stored value is her actual reply, not a regenerated shadow. API path /api/admin/addie/threads/:id already returns the full thread context (`...thread` spread), so the new fields are exposed without any server work. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * review: render missing ratio as '?' for consistency with word_count Reviewer nit: `ratio_to_expected ?? 0` rendered a missing ratio as '0.00' while sibling `word_count ?? '?'` rendered '?'. Both fields come from the same persisted shape summary, so a missing one of them should read the same way. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
2 of 5 tasks
bokelley
added a commit
that referenced
this pull request
Nov 22, 2026
… runner sends them @adcp/sdk 17.0.0-beta.33 lets the storyboard runner send refine_proposals action extend_hold (adcontextprotocol/adcp-client#3601, closed by #3738), so on beta.35 media_buy_seller/hold_extension runs every step: 32 passed, 0 skipped. The /sales storyboard job failed only because the required-exact pin still expected 22 passed / 10 skipped. Re-pin it in the workflow and run-storyboards-matrix.sh, and drop the three extend_hold quarantine entries whose removal condition (#3601) is met. Co-Authored-By: Claude Opus 5.5 <[email protected]>
bokelley
added a commit
that referenced
this pull request
Nov 23, 2026
… preview to 3.3-rc.3 (#9178) * chore(deps): bump @adcp/sdk to 17.0.0-beta.35 and move the test-agent preview to 3.3-rc.3 @adcp/sdk 17.0.0-beta.35 pins AdCP 3.3.0-rc.3 and negotiates exactly 3.3-rc.3, so TRAINING_AGENT_HOSTED_PREVIEW moves to { wireVersion: '3.3-rc.3', bundle: '3.3.0-rc.3' } in the same change; the preview-version and tenant-smoke tests follow, with 3.3-rc.0 as the previous preview. beta.33 added extend_hold to the SDK's refinement union (adcp-client #3738). The training profile never evaluates one (holds/service.ts serves it and createProposalRefinementHandler refuses it first), so a guard narrows the type. Docs: Choose your SDK, the 3.3 prerelease page, Versions, the quickstart and the creative33 sandbox note name beta.35 and the rc.3 preview. Python adcp 10.0.0b21 still bundles rc.0, so a TS/Python pair falls back to 3.2. The SDK response-conformance baseline is re-captured with beta.35 and matches apart from the recorded SDK version. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(3.3): the test-agent preview serves include_collections on list_products, not get_products Cold-review finding: get_products lost include_collections in beta.6, and the training agent never returns collections there (collections/include-collections.ts), but the preview's surface list still named it. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(storyboards): grade hold_extension's extend_hold steps now the SDK runner sends them @adcp/sdk 17.0.0-beta.33 lets the storyboard runner send refine_proposals action extend_hold (adcontextprotocol/adcp-client#3601, closed by #3738), so on beta.35 media_buy_seller/hold_extension runs every step: 32 passed, 0 skipped. The /sales storyboard job failed only because the required-exact pin still expected 22 passed / 10 skipped. Re-pin it in the workflow and run-storyboards-matrix.sh, and drop the three extend_hold quarantine entries whose removal condition (#3601) is met. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(3.3): say beta.6 withdrew include_collections from get_products, not the task Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(3.3): name no checkpoint for the get_products include_collections withdrawal The closed-schema triage removed include_collections and collections from get_products: the v3.3.0-beta.5 schemas declare them, v3.3.0-beta.6 and v3.3.0-rc.0 do not. Naming the triage rather than a checkpoint keeps the sentence true and consistent with the rest of the page. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
The Katie/registry Slack thread is the canonical case: 24-word multi-part question → 280-word response with bold headings, nested bullets, closing follow-up question. Brian's TLDR was 37 words. The rule files already explicitly forbid this shape but: (1) shape regressions weren't being measured at all, (2) the corpus didn't include the load-bearing case, (3) the documented "shape rules last" intent was contradicted by the actual prompt assembly order.
Empirical result (Sonnet 4.6, 12-question battery)
Variant B is unambiguously cleanest: -13% mean response length, zero default-template hits, zero banned rituals, no rule content removed. The dedupe and content-removal variants did NOT help and are NOT shipped — their findings are recorded in `.context/addie-rules-conflict-audit.md` for follow-up review.
What's in this PR
Closes
Deferred (next PRs, with audit available)
Test plan
🤖 Generated with Claude Code