FE-1667: Run experiments from Petrinaut AI chat - #9678
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
PR SummaryMedium Risk Overview While a tool call runs, the UI shows a dedicated experiment card (blue simulation / purple optimization) with live progress, Cancel, View experiment navigation, and a single captured tool result when work finishes. Abort and stale-result guards cover stop, clear, conversation switches, and reused tool call IDs. Editor layout keeps Reviewed by Cursor Bugbot for commit 0755061. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
🟡 Changes recommended
AI optimization currently bypasses the required Parameter sweeps feature flag.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds AI-driven Petrinaut experiments with live progress, cancellation, result cards, and persistent chat across editor modes.
Changes:
- Registers and executes
createExperiment. - Adds experiment cards, lifecycle handling, and tests.
- Updates architecture docs, user guides, and changesets.
File summaries
| File | Description |
|---|---|
libs/@local/petrinaut-arch-docs/content/experiments/ai-created-experiments.mdx |
Links browser-host and chat architecture. |
libs/@local/petrinaut-arch-docs/content/diagrams/ai-experiment-chat.d2 |
Adds chat experiment flow diagram. |
libs/@local/petrinaut-arch-docs/content/ai/experiment-chat.mdx |
Documents chat integration. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/types.ts |
Adds experiment tool message types. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/README.md |
Declares the AI panel architecture layer. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/format-diagnostics-for-ai.ts |
Clarifies experiment compilation behavior. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/format-diagnostics-for-ai.test.ts |
Updates diagnostics expectation. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/ai-assistant-contents/get-message-render-items.ts |
Routes experiment parts to cards. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/ai-assistant-contents/experiment-card.tsx |
Implements progress and result cards. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/ai-assistant-contents/experiment-card.test.tsx |
Tests card states and progress. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/ai-assistant-contents.tsx |
Renders experiment state and controls. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel.tsx |
Dispatches and manages experiment requests. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel.test.tsx |
Tests experiment lifecycle integration. |
libs/@hashintel/petrinaut/src/ui/views/Editor/editor-view.tsx |
Keeps chat mounted across modes. |
libs/@hashintel/petrinaut/src/ui/views/Editor/editor-view.test.tsx |
Verifies persistent panel mounting. |
libs/@hashintel/petrinaut/docs/experiments.md |
Documents assistant-created experiments. |
libs/@hashintel/petrinaut/docs/ai-assistant.md |
Documents chat experiment workflows. |
libs/@hashintel/petrinaut-core/src/index.ts |
Exports the experiment tool name. |
libs/@hashintel/petrinaut-core/src/ai.ts |
Registers the canonical tool schema. |
.changeset/small-experiments-chat.md |
Records the Petrinaut package change. |
.changeset/experiment-ai-tool.md |
Records the core package change. |
Review details
- Files reviewed: 21/21 changed files
- Comments generated: 1
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| experimentControllersRef.current.get(toolCall.toolCallId) === | ||
| controller; | ||
| try { | ||
| const result = await experimentHost.createExperiment(request, { |
b090aa6 to
0755061
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0755061. Configure here.
| for (const controller of experimentControllersRef.current.values()) | ||
| controller.abort(); | ||
| experimentControllersRef.current.clear(); | ||
| setExperimentStates({}); |
There was a problem hiding this comment.
Aborted experiment stays pending
Medium Severity
Changing conversations aborts an in-flight experiment and clears experimentStates without writing a cancelled tool result onto that conversation. Returning to it leaves the card on Validating with a no-op Cancel, because the part is still input-available and the prior execution key is not run again.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 0755061. Configure here.


Important
Experimental optimization
Optimization requires Parameter sweeps and In-browser optimization. Simulation is available without these flags.
Summary
Petrinaut AI can create experiments through the browser host and show their progress in the conversation. A compact card provides cancellation, the final metric, and a link to the experiment drawer.
The conversation stays mounted while the user inspects an experiment. Completion returns one captured tool result with the original call ID.
Links
Blocked by
Changes
createExperimentwith its canonical schema and dispatch it from the AI panelTest coverage
After the 14 September rebase, affected package builds, unit tests, types, lint and architecture checks passed on the integrated stack. Browser recordings and manual checks listed below predate this rebase.
Local package builds, unit tests, TypeScript, lint, architecture validation, and the docs site build pass.
How to test
yarn workspace @hashintel/petrinaut test:unit --run src/ui/views/Editor/panels/ai-assistant-panel.test.tsx src/ui/views/Editor/panels/ai-assistant-panel/ai-assistant-contents/experiment-card.test.tsx src/ui/views/Editor/editor-view.test.tsx