Skip to content

FE-1484: Run experiments from Petrinaut AI chat - #9654

Draft
kube wants to merge 7 commits into
claude/opt-proto-experiment-optimizerfrom
codex/fe-1484-ai-experiments
Draft

FE-1484: Run experiments from Petrinaut AI chat#9654
kube wants to merge 7 commits into
claude/opt-proto-experiment-optimizerfrom
codex/fe-1484-ai-experiments

Conversation

@kube

@kube kube commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Important

Experimental optimization
Optimization requires Parameter sweeps and In-browser optimization. Simulation and the diagnostics API work without these flags.

Summary

Petrinaut AI can create an Experiment from chat, show its progress, and receive a captured result when it finishes. The same request can optimize a parameter range, then finish the requested runs at the best point.

The browser host owns validation and execution. Integrating applications consume a shared contract; Brunch continues to own its tool selection and agent behavior. The website demo uses scripted chat replies and real browser computation, with that boundary stated on screen.

Links

Blocked by

Changes

Contract and browser host

  • Add shared Zod request/result schemas and the PetrinautExperimentHost interface

    Requests use saved scenario and metric IDs, fixed values or parameter ranges, and bounded run budgets. The host captures the model and validates references and code before creating an experiment.

  • Protect computation inputs until the host captures the terminal result

    The user can inspect and cancel a running request. Later exploration preserves the result already returned to chat.

  • Retain metric distributions for heatmaps and histograms, including after optimization

    Chat receives the mean of the final sampled distribution; the experiment keeps the spread across runs for exploration.

  • Replace UI diagnostics polling with a correlated language-worker snapshot request

Chat and integration demo

  • Show compact blue simulation cards and purple optimization cards with an active glow

    Status and run count sit beside the title; metrics share a row with the View experiment action. Progress animates between reported values. Active indicators stop on completion and respect reduced-motion preferences.

  • Keep chat mounted across editor views and show completion notifications
  • Add the /ai-experiments demo with planning turns, streamed replies, and completion figures from the returned experiment result

    The illustrative SIR model uses fixed simulation and search recipes. The demo documents separate client and host responsibilities; Brunch's production catalog, prompts, and transport remain unchanged.

  • Externalize React runtime subpaths so the website can load the library in a browser

Known issues

  • Execution lasts for the mounted browser host; durable jobs remain a follow-up
  • Requests use saved scenarios and metrics on the CPU backend; metrics use the last sampled frame and means across runs
  • Diagnostics requests have no timeout for an unresponsive language worker

The architecture guide marks these limits and the future host-orchestration extraction with Important blocks.

Next steps

Brunch adoption needs catalog admission and continuation tests against its real transport. User-guide screenshots remain pending for AI assistant › Experiments from chat and Experiments › Experiments created by the assistant.

Test coverage

  • Core suites cover schema bounds, invalid requests, and correlated diagnostics
  • Host suites cover captured inputs, ownership, completion, optimization refinement, and cancellation
  • Chat suites cover tool-result identity, conversation changes, view navigation, card status, and accessible progress
  • Website suites cover planning turns, streamed text before tool calls, returned result values, continuation, and cancellation during reply delays

Local verification passed: 995 React tests, 399 website tests, TypeScript, lint, package builds, formatting, architecture checks, and the 131-page docs build. Browser checks cover real simulation and optimization, distribution heatmaps and histograms, cancellation, protected controls, captured results, and normal/reduced-motion behavior.

How to test

Simulation

  • Check out this branch and run turbo run dev --filter @apps/petrinaut-website
  • Open /ai-experiments on the printed local URL
  • Open AI assistant and ask How can I see the variation in this outbreak model?

    A streamed reply describes the baseline without starting an experiment.

  • Send Run 256 simulations for 20 model-time units. and watch the blue card

    The card shows progress, then its metric and a completion notification.

  • Select View experiment to inspect the metric heatmap
  • Click a time step in the heatmap to inspect its histogram

Optimization

  • Open /ai-experiments and select Edit > Settings > Simulation
    • Enable Parameter sweeps and In-browser optimization, then close Settings
  • Open AI assistant and ask Can we compare different starting infection levels?
  • Send Optimize for the lowest infected share.

    The purple card shows optimization steps and refinement. The final reply reports the selected starting share and returned metric.

  • Select View experiment to inspect the best parameter value and distribution heatmap
  • Click a time step to inspect its histogram across the completed runs

Ownership and cancellation

  • Send optimize, then select View experiment while it runs

    Compute controls are read-only until the request finishes.

  • Close the drawer and select Cancel on the active card

    The card becomes Cancelled and stops animating.

  • Complete a new optimization, then explore another parameter value

    The earlier result in chat stays unchanged.

@vercel

vercel Bot commented Sep 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
petrinaut Ready Ready Preview Sep 11, 2026 2:52am UTC
petrinaut-docs Ready Ready Preview Sep 11, 2026 2:52am UTC
2 Skipped Deployments
Project Deployment Actions Updated
hash Ignored Ignored Preview Sep 11, 2026 2:52am UTC
hashdotdesign-tokens Ignored Ignored Preview Sep 11, 2026 2:52am UTC

Request Review

@github-actions github-actions Bot added area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team type/eng > backend Owned by the @backend team area/apps labels Sep 11, 2026
@kube kube self-assigned this Sep 11, 2026
@kube kube changed the title Run experiments from Petrinaut AI chat FE-1484: Run experiments from Petrinaut AI chat Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

1 participant