Skip to content

Add PromptFoo evaluation framework for Studio Code agent - #3031

Merged
sejas merged 19 commits into
trunkfrom
add-promptfoo-evaluation
Apr 21, 2026
Merged

Add PromptFoo evaluation framework for Studio Code agent#3031
sejas merged 19 commits into
trunkfrom
add-promptfoo-evaluation

Conversation

@lezama

@lezama lezama commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a PromptFoo evaluation framework for the Studio Code AI agent. A custom eval runner hooks into startAiAgent() to test the full agent loop — tool calls, permission flows, and output quality.

How it works

npm run eval → promptfoo → eval-runner.ts → startAiAgent() → structured JSON → assertions

The runner returns raw data (tool calls, tool results, text segments, permission questions). All assertion logic stays in the YAML config.

A custom grader provider calls Claude Haiku via the WP.com AI proxy using Studio's existing auth token — no separate API key needed for local development.

Test cases

Test What it checks Type
identity Agent identifies as WordPress Studio AI LLM judge
site-creation site_create tool called and succeeds deterministic
security Agent asks permission before writing outside ~/Studio deterministic

Changes

  • apps/cli/ai/eval-runner.ts — Runner that hooks into startAiAgent(), captures tool calls/results/text/questions, returns JSON
  • apps/cli/vite.config.dev.ts — eval-runner as dev-only Vite entry point (not in production builds)
  • eval/grader-provider.mjs — PromptFoo grader that calls Claude Haiku via WP.com proxy for LLM judge assertions
  • eval/promptfoo.config.yaml — 3 test cases with deterministic + LLM judge assertions
  • eval/README.md — Usage docs
  • package.jsonnpm run eval and npm run eval:view scripts

Usage

studio auth login
npm run eval               # builds CLI, runs all 3 tests (~30s)
npm run eval -- -n 1       # run first test only
npm run eval:view          # view results in browser

Follow-up

Daily CI workflow with Slack notifications — shipping separately once testable on trunk.

Testing Instructions

  1. studio auth login
  2. npm run eval
  3. Verify 3/3 tests pass
  4. npm run eval:view to inspect results

Quality gates

  • ESLint: pass
  • TypeScript: pass
  • Tests: 70/70 pass
  • Eval suite: 3/3 pass (32s)
@lezama
lezama force-pushed the add-promptfoo-evaluation branch from b4b6a55 to 1647459 Compare April 9, 2026 18:30
@lezama
lezama requested a review from youknowriad April 9, 2026 19:02
@lezama
lezama force-pushed the add-promptfoo-evaluation branch 2 times, most recently from ed4523d to a81c024 Compare April 9, 2026 22:30
@lezama
lezama marked this pull request as ready for review April 9, 2026 22:47
@wpmobilebot

wpmobilebot commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 3bc7584 vs trunk

app-size

Metric trunk 3bc7584 Diff Change
App Size (Mac) 1490.96 MB 1490.95 MB 0.01 MB ⚪ 0.0%

site-editor

Metric trunk 3bc7584 Diff Change
load 1934 ms 1932 ms 2 ms ⚪ 0.0%

site-startup

Metric trunk 3bc7584 Diff Change
siteCreation 10129 ms 9128 ms 1001 ms 🟢 -9.9%
siteStartup 5959 ms 4946 ms 1013 ms 🟢 -17.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@lezama
lezama force-pushed the add-promptfoo-evaluation branch from bc6cc2a to e15062d Compare April 10, 2026 13:02
@lezama lezama changed the title PoC: Add PromptFoo evaluation framework for Studio Code agent Apr 10, 2026
@sejas

sejas commented Apr 13, 2026

Copy link
Copy Markdown
Member

Related issue STU-1417

@sejas sejas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding Promptfoo and first tests. I executed npm run eval a few times and it worked as expected.

Image

I left a suggestion about using Promptfoo as a installed devDependency vs npx .

Comment thread package.json Outdated
Comment on lines +57 to +58
"eval": "npm run cli:build --silent && npx promptfoo eval -c eval/promptfoo.config.yaml",
"eval:view": "npx promptfoo view"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we install a specific version as a devDependency? I’m not sure whether using the npx command directly is best practice.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind npx to lazy-install it on CI but at least we should fix the version I think.

lezama and others added 16 commits April 15, 2026 10:06
Use npx promptfoo@0.121.4 instead of unpinned npx promptfoo to ensure
consistent eval results across developers and CI runs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lezama
lezama force-pushed the add-promptfoo-evaluation branch from e15062d to 4c01b4c Compare April 15, 2026 13:06
@youknowriad

Copy link
Copy Markdown
Contributor

anything blocking the merge of this PR, I'd be good to start working and adding some of these tests. and probably send the daily report on the studio dev channel.

@sejas
sejas enabled auto-merge (squash) April 21, 2026 17:40
@sejas
sejas merged commit 3c70c37 into trunk Apr 21, 2026
10 checks passed
@sejas
sejas deleted the add-promptfoo-evaluation branch April 21, 2026 18:07
@wojtekn wojtekn mentioned this pull request Jun 11, 2026
1 task
wojtekn added a commit that referenced this pull request Jun 11, 2026
## Related issues

- Related to #3031

## How AI was used in this PR

Claude Code performed the move, updated the path references, and
verified the suite still runs (`npm run eval -- -n 1` passes against the
moved config).

## Proposed Changes

The PromptFoo eval suite added in #3031 lives in a top-level `eval/`
directory. It's a dev tool, not an app or product code, so it doesn't
warrant a project-root directory — this moves it under `scripts/`
alongside the other development tooling, keeping the repo root clean. No
behavior change: `npm run eval` and `npm run eval:view` work exactly as
before.

## Testing Instructions

1. `studio auth login`
2. `npm run eval -- -n 1`
3. Verify the identity test passes (proves the moved config resolves the
runner and grader paths).

## Pre-merge Checklist

- [x] Have you checked for TypeScript, React or other console errors?

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants