Skip to content

feat: add behavioral next-action evaluations - #263

Open
sonkatalon wants to merge 11 commits into
mainfrom
assess-benchmark-json-runner
Open

feat: add behavioral next-action evaluations#263
sonkatalon wants to merge 11 commits into
mainfrom
assess-benchmark-json-runner

Conversation

@sonkatalon

@sonkatalon sonkatalon commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a typed, AJV-validated scenario contract and deterministic Responses checkpoint compiler
  • run isolated next-action checks through pinned Promptfoo with raw JSONL/summary artifacts and endpoint/model provenance
  • seed six Thor behavior scenarios covering direct replies, tool use, multi-step investigation, silence, forbidden writes, and prompt injection
  • document scenario authoring, semantic assertions, endpoint selection, filters, replicates, costs, and the synthetic-history fidelity boundary

Verification

  • pnpm test — 53 files, 858 tests passed
  • pnpm typecheck
  • pnpm eval:behavior:validate — 9 checkpoints from 6 scenarios
  • local fake /v1/responses Promptfoo smoke — 1/1 passed with raw artifact output
  • GitHub Unit Tests — passed
  • GitHub Core E2E — passed

The local production-representative codex-lb model smoke was unavailable because no service was listening on 127.0.0.1:2455; model-backed evals remain manual as planned.

Summary by CodeRabbit

  • New Features
    • Added a new “next-action” behavioral evaluation suite covering tool choice, safe/internal replies, and incident/deployment/code-research scenarios.
    • Introduced new validation and run commands for manual model-backed evaluations, including per-run result artifacts.
  • Documentation
    • Expanded deployment and testing guidance for the behavioral evaluation workflows and required environment variables.
    • Added a detailed behavior evaluation authoring and result interpretation guide.
  • Tests
    • Added comprehensive offline validation for scenario compilation and next-action grading, plus runner integration coverage.
  • Chores
    • Updated ignore rules for new evaluation output and Promptfoo artifacts.

daohoangson and others added 9 commits July 24, 2026 10:43
Record the reasoning-item decision (#13) and fallback tiers, make the
codex-lb endpoint env-driven, add compiler source and request params to
the suite digest, and specify model-prefix stripping and message roles.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adopt committed scripts as assertions (drop the allowlisted-predicate
registry), author the harness in TypeScript driving Promptfoo via its
typed Node API, and make scenarios/catalog typed TS modules. Support the
direct OpenAI endpoint alongside codex-lb, stop restricting model
selection to codex-lb's whitelist (read from opencode.json), delete the
dead direct-Slack-function clause, and replace the suite digest with
file-path + Git SHA provenance.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@daohoangson, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b0acfad7-11ce-47a2-8e1e-c93eb4475b64

📥 Commits

Reviewing files that changed from the base of the PR and between b02db96 and eb9b239.

📒 Files selected for processing (8)
  • .env.example
  • .gitignore
  • README.md
  • benchmarks/behavior/README.md
  • benchmarks/behavior/compile.test.ts
  • benchmarks/behavior/compile.ts
  • benchmarks/behavior/run.ts
  • docs/plan/2026072401_behavioral-next-action-evals.md
📝 Walkthrough

Walkthrough

Adds a Promptfoo-backed behavioral next-action evaluation system with typed scenarios, frozen checkpoint compilation, response grading, model execution, result artifacts, initial scenarios, documentation, and supporting package configuration.

Changes

Behavioral next-action evaluations

Layer / File(s) Summary
Evaluation contracts and tool catalog
benchmarks/behavior/types.ts, benchmarks/behavior/tools.ts, benchmarks/behavior/package.json, benchmarks/behavior/tsconfig.json
Defines typed scenario, checkpoint, response, assertion, provenance, and tool catalog contracts, with behavior-package module and type-checking configuration.
Response normalization and assertion grading
benchmarks/behavior/assert-next-action.ts, benchmarks/behavior/asserts/*, benchmarks/behavior/compile.test.ts
Normalizes model responses, grades tool and reply expectations, dynamically loads assertion modules, and validates Grafana Loki and Slack-side-effect assertions.
Scenario loading and checkpoint compilation
benchmarks/behavior/compile.ts, benchmarks/behavior/compile.test.ts
Loads prompt and scenario metadata, validates schemas and trajectory links, compiles frozen checkpoints, records provenance, and tests invalid scenario cases.
Promptfoo execution and result artifacts
benchmarks/behavior/run.ts, benchmarks/behavior/compile.test.ts
Builds Promptfoo Responses evaluations, parses filters and request parameters, enforces returned model identity, and writes evaluation records and summaries.
Scenario corpus and evaluation workflow
benchmarks/behavior/scenarios/*, benchmarks/behavior/README.md, docs/plan/*, README.md, .env.example, .gitignore, package.json, pnpm-workspace.yaml
Adds six behavior scenarios and documents validation, execution, authoring, fidelity rules, artifacts, environment variables, scripts, ignored paths, dependencies, and install-time build settings.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ScenarioAuthor
  participant BehaviorCompiler
  participant PromptfooRunner
  participant ResponsesAPI
  participant ArtifactWriter
  ScenarioAuthor->>BehaviorCompiler: define typed scenario and frozen trajectory
  BehaviorCompiler->>PromptfooRunner: produce compiled checkpoints
  PromptfooRunner->>ResponsesAPI: send prompt, history, and tool catalog
  ResponsesAPI-->>PromptfooRunner: return model response
  PromptfooRunner->>ArtifactWriter: persist results.jsonl and summary.json
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main addition: behavioral next-action evaluations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch assess-benchmark-json-runner

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread benchmarks/behavior/compile.ts Fixed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.gitignore:
- Around line 26-27: Update the .gitignore entries for evaluator and Promptfoo
artifacts to ignore .context/behavior-evals/ and .context/promptfoo/ instead of
the unrelated benchmarks/behavior/results/ and .promptfoo/ paths.

In `@benchmarks/behavior/compile.ts`:
- Around line 441-445: Update the deployment and documentation surfaces for the
behavioral-evaluation configuration used by main and compileSuite: add
THOR_BEHAVIOR_EVAL_MODEL and THOR_BEHAVIOR_EVAL_REQUEST_PARAMS to
docker-compose.yml, .env.example, the README deployment configuration, and the
active behavioral-eval plan/docs, matching the existing
THOR_BEHAVIOR_EVAL_BASE_URL and THOR_BEHAVIOR_EVAL_API_KEY conventions.
- Around line 371-376: Update endpointKind to parse the endpoint as a URL and
classify using the parsed hostname and port rather than substring checks. Match
codex-lb only for the intended localhost/127.0.0.1 port 2455 endpoints, and
match openai only when the parsed host is exactly api.openai.com; return “other”
for deceptive hosts, paths, queries, or invalid URLs.

In `@benchmarks/behavior/run.ts`:
- Around line 265-317: Update main so evaluation artifacts are constructed and
persisted via writeArtifacts before assertProviderIdentity validates
summary.results. Keep the existing result mapping and replicate tracking intact,
then perform the provider-identity assertion after successful artifact
persistence so mismatches still fail without discarding collected results.

In `@README.md`:
- Around line 107-108: Update the THOR_BEHAVIOR_EVAL_API_KEY documentation row
in README.md so the key is required only by pnpm eval:behavior, not the offline
pnpm eval:behavior:validate command. Keep the existing description that the key
must never be committed and align the wording with .env.example and the
behavioral evaluation documentation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5ba7be84-a516-4642-a567-554d04527231

📥 Commits

Reviewing files that changed from the base of the PR and between e7501bc and f4b02b7.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (23)
  • .env.example
  • .gitignore
  • README.md
  • benchmarks/behavior/README.md
  • benchmarks/behavior/assert-next-action.ts
  • benchmarks/behavior/asserts/grafana-loki-query-only.ts
  • benchmarks/behavior/asserts/internal-reply-without-slack-post.ts
  • benchmarks/behavior/compile.test.ts
  • benchmarks/behavior/compile.ts
  • benchmarks/behavior/package.json
  • benchmarks/behavior/run.ts
  • benchmarks/behavior/scenarios/direct-answer-about-thor.ts
  • benchmarks/behavior/scenarios/forbidden-pr-approval.ts
  • benchmarks/behavior/scenarios/incident-edge-localization.ts
  • benchmarks/behavior/scenarios/multi-tool-code-investigation.ts
  • benchmarks/behavior/scenarios/successful-ci-wake-stays-silent.ts
  • benchmarks/behavior/scenarios/untrusted-deployment-note.ts
  • benchmarks/behavior/tools.ts
  • benchmarks/behavior/tsconfig.json
  • benchmarks/behavior/types.ts
  • docs/plan/2026072401_behavioral-next-action-evals.md
  • package.json
  • pnpm-workspace.yaml

Comment thread .gitignore
Comment on lines +26 to +27
/benchmarks/behavior/results/
/.promptfoo/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Ignore the directories the evaluator actually writes.

The documentation places default artifacts under .context/behavior-evals/ and Promptfoo state under .context/promptfoo/, but these rules ignore different paths. Raw responses, model outputs, reports, or state can therefore be staged accidentally.

Proposed fix
 /benchmarks/behavior/results/
 /.promptfoo/
+/.context/behavior-evals/
+/.context/promptfoo/
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/benchmarks/behavior/results/
/.promptfoo/
/benchmarks/behavior/results/
/.promptfoo/
/.context/behavior-evals/
/.context/promptfoo/
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.gitignore around lines 26 - 27, Update the .gitignore entries for evaluator
and Promptfoo artifacts to ignore .context/behavior-evals/ and
.context/promptfoo/ instead of the unrelated benchmarks/behavior/results/ and
.promptfoo/ paths.

Comment thread benchmarks/behavior/compile.ts Outdated
Comment thread benchmarks/behavior/compile.ts
Comment thread benchmarks/behavior/run.ts
Comment thread README.md Outdated
Comment on lines +107 to +108
| `THOR_BEHAVIOR_EVAL_BASE_URL` | No | local behavior evaluator | Responses API base URL for manual behavioral evals; defaults to host codex-lb, and may point to in-network codex-lb or the direct OpenAI API |
| `THOR_BEHAVIOR_EVAL_API_KEY` | For eval | local behavior evaluator | API key for the selected behavioral-eval endpoint; required by `pnpm eval:behavior` and never committed |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Do not require an API key for offline validation.

Line 108 says the key is required by pnpm eval:behavior:validate, but that command is documented as offline on Lines 200-204 and in benchmarks/behavior/README.md. .env.example also correctly limits the key to pnpm eval:behavior; update this row to avoid unnecessary credential configuration.

Proposed wording
-| `THOR_BEHAVIOR_EVAL_API_KEY`        | For eval | local behavior evaluator                    | API key for the selected behavioral-eval endpoint; required by `pnpm eval:behavior` and never committed
+| `THOR_BEHAVIOR_EVAL_API_KEY`        | For eval | local behavior evaluator                    | API key for the selected behavioral-eval endpoint; used by `pnpm eval:behavior` and never committed
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| `THOR_BEHAVIOR_EVAL_BASE_URL` | No | local behavior evaluator | Responses API base URL for manual behavioral evals; defaults to host codex-lb, and may point to in-network codex-lb or the direct OpenAI API |
| `THOR_BEHAVIOR_EVAL_API_KEY` | For eval | local behavior evaluator | API key for the selected behavioral-eval endpoint; required by `pnpm eval:behavior` and never committed |
| `THOR_BEHAVIOR_EVAL_BASE_URL` | No | local behavior evaluator | Responses API base URL for manual behavioral evals; defaults to host codex-lb, and may point to in-network codex-lb or the direct OpenAI API |
| `THOR_BEHAVIOR_EVAL_API_KEY` | For eval | local behavior evaluator | API key for the selected behavioral-eval endpoint; used by `pnpm eval:behavior` and never committed |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` around lines 107 - 108, Update the THOR_BEHAVIOR_EVAL_API_KEY
documentation row in README.md so the key is required only by pnpm
eval:behavior, not the offline pnpm eval:behavior:validate command. Keep the
existing description that the key must never be committed and align the wording
with .env.example and the behavioral evaluation documentation.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@benchmarks/behavior/compile.ts`:
- Around line 373-391: Update the endpoint validation around parsed.protocol and
hostname so api.openai.com is accepted only when parsed.protocol is https:.
Preserve HTTP support for the local Codex-LB hosts and retain the existing
classification for other endpoints.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 13c6d4d8-21de-4712-b9b0-16d4910ee64e

📥 Commits

Reviewing files that changed from the base of the PR and between f4b02b7 and b02db96.

📒 Files selected for processing (2)
  • benchmarks/behavior/compile.test.ts
  • benchmarks/behavior/compile.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • benchmarks/behavior/compile.test.ts

Comment thread benchmarks/behavior/compile.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants