Skip to content

[feat] Run a scenario's invocation from the /m evaluation run page - #8103

Merged
mmabrouk merged 4 commits into
release/v0.128.7from
feat/m-run-scenario-invocation
Nov 4, 2026
Merged

mmabrouk merged 4 commits into
release/v0.128.7from
feat/m-run-scenario-invocation

Conversation

@mmabrouk

@mmabrouk mmabrouk commented Nov 4, 2026

Copy link
Copy Markdown
Member

Pre-preview: run a scenario's invocation from the hidden /m evaluation run page.

Context

A human evaluation created in /m could not be annotated. Every scenario said "Run the invocation to generate output before annotating.", and /m had no Run button, so the user had to open the run in /w and press Run there for each scenario. The page is behind the evaluations developer view.

Changes

runScenarioInvocation({projectId, runId, scenarioId, stepKey}) is new in @agenta/playground. It does what the /w run action does for one scenario: it reads the app revision from the run's invocation step, loads the scenario's test case, calls the app with executeWorkflowRevision, stores the step result (POST /evaluations/results/ with the trace and span ids, the references and the outputs), marks the scenario failure when the app fails, refreshes the scenario and run metrics, and drops the cached scenario steps and run metrics. A second call for the same scenario while one runs joins the first one and sends nothing. It returns {ok: true} or {ok: false, reason, detail}; it never shows the raw error.

In the Annotate tab and the annotate sheet of a human run, a scenario without output now shows "Generate output to annotate" with a Run button where the form will be. While it runs: "Generating output..." and "Running...". On success: the toast "Invocation completed", then the output and the form. On failure: "Couldn't run this scenario" with "Run again" (the detail goes to the console). Cmd or Ctrl+Enter runs the app while the scenario has no output, and saves the form after. Nothing runs when a scenario opens, so browsing spends no model credits. Run needs edit_evaluation_results and is hidden on a closed run. /w has no "Run all", so there is none here.

The runner code loads only when Run is clicked. Size (first-load JS, gzip, against an origin/main build): app shell 955.2 KB to 955.3 KB, run details 1097.5 KB to 1097.6 KB. To get there, executeWorkflowRevision now calls the runner through executionItemController.helpers.executeStepForSession instead of importing executionRunner directly. The function is the same; /w behaves as before. The reason: the /m shell already holds the runner, merged into one module. A direct import from an on-demand chunk made Turbopack split that module, and the shell grew by 1.2 KB. A control build without the import confirmed this.

/w bugs found (not changed in /w; fixed in the shared function)

  • A successful "Run again" after a failure leaves the scenario failure. Now the scenario goes back to pending before the success is stored.
  • Run calls the app on a closed run, and the API then refuses the result. Now a closed run does not call the app.
  • An app answer without a trace id is stored as success, which leaves a scenario with no output to annotate and no Run button. Now it is stored as a failure.
  • When the test case does not load, /w calls the app with empty inputs. Now the call stops with request-failed.
  • /w shows the raw API error text in a toast for 8 seconds.

Tests

  • @agenta/playground: evaluationRunInvocation.test.ts runs the real executeWorkflowRevision and the entity code with only axios and fetch mocked. It asserts the app request inputs, the exact result upsert for success and failure, the scenario status writes, the metric refreshes, the in-flight guard, and the missing-reference, closed-run, no-trace and request-failure paths.
  • /m: runAnnotateTab.render.test.tsx adds 8 render tests with the real controllers and HTTP mocked: the Run panel, no request before Run, Run then annotate (exact upsert body), failure then Run again, permission, closed run, the keyboard, and the sheet.
  • Passed: /m and /w type checks, @agenta/playground tests (302), /m lint (0 errors), full /m suite except playgroundRevisionActions.render.test.tsx, which fails the same way on origin/main and passes alone on this branch. speed:check passes.
  • Live check on a fresh OSS dev stack with mistral-small-latest: created a human evaluation in /m, ran scenario 1 from the Annotate tab and scenario 2 from the row sheet, annotated both, reloaded. Outputs and annotations stayed, scenario 3 still showed Run, and the stored results have success and a trace id. No console errors.
  • Review: slop, simplify and correctness lenses, then a correctness pass on the final head (Low).

What to QA

  • Enable the evaluations developer view. Create a human evaluation in /m and open its Annotate tab. The first scenario shows "Generate output to annotate" and Run. Click Run: "Running...", then "Invocation completed", the output and the form. Annotate and save.
  • On the Scenarios tab, open a row's Annotate sheet for another scenario. Run works there too.
  • Reload. Annotated scenarios keep their output and values; the others still show Run.
  • Regression: a run that /w already invoked opens on the form, with no Run button.

Agenta Product Agent added 4 commits November 4, 2026 18:09
…n page

Add runScenarioInvocation to @agenta/playground and a Run button in the
Annotate tab and the annotate sheet of a human run, so a run made in /m
can be annotated without opening /w.
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 0550f9c and 0550f9c.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
Summary

Summary by CodeRabbit

  • New Features
    • Run an app directly from an evaluation scenario when its output is pending, then annotate the generated result.
    • View progress while the app runs and retry after a failed run.
    • Use the annotation keyboard shortcut to run a pending app or submit annotations when output is ready.
    • Run controls respect permissions and are unavailable for closed evaluation runs.

The change adds on-demand execution for human invocation steps in evaluation runs. It stores scenario results and updates related metrics. The mobile annotate interface displays invocation status and gates annotation submission until output is available.

Changes: Human scenario invocation

Layer / File(s) Summary
Execute and store invocation results
web/packages/agenta-playground/src/state/evaluationRunInvocation.ts, web/packages/agenta-playground/src/state/controllers/executionItemController.ts, web/packages/agenta-playground/src/executeWorkflowRevision.ts, web/packages/agenta-playground/src/index.ts, web/packages/agenta-playground/tests/unit/evaluationRunInvocation.test.ts
The playground loads invocation references and testcase data, executes the workflow revision, and stores the result. It handles failed and closed runs, coalesces concurrent calls for the same scenario and step, refreshes metrics, and invalidates related queries. The tests cover these outcomes and result ID conversion.
Run action in the annotate flow
web/mobile/src/features/evaluation-run/focus/RunAnnotateBody.tsx, web/mobile/src/features/evaluation-run/focus/RunAnnotateSheet.tsx, web/mobile/src/features/evaluation-run/focus/RunAnnotateTab.tsx, web/mobile/src/features/evaluation-run/focus/RunInvocationPanel.tsx, web/mobile/src/features/evaluation-run/focus/runScenarioInvocation.ts, web/mobile/src/features/evaluation-run/focus/useScenarioInvocation.ts, web/mobile/tests/unit/runAnnotateTab.render.test.tsx
The annotate interface uses invocation state to show a Run action, running status, or failure alert. It gates annotation submission while invocation is pending and supports running through the keyboard shortcut and annotation sheet. Tests cover permissions, closed runs, retries, and subsequent annotation.

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

Sequence Diagram(s)

sequenceDiagram
  participant AnnotateTab as RunAnnotateTab
  participant InvocationHook as useScenarioInvocation
  participant InvocationRunner as runScenarioInvocation
  participant EvaluationAPI
  participant WorkflowRevision as executeWorkflowRevision
  AnnotateTab->>InvocationHook: Run action for scenario
  InvocationHook->>InvocationRunner: Load and call runner
  InvocationRunner->>EvaluationAPI: Load run and testcase references
  InvocationRunner->>WorkflowRevision: Execute revision with testcase data
  WorkflowRevision-->>InvocationRunner: Return execution result
  InvocationRunner->>EvaluationAPI: Store result and refresh metrics
  InvocationRunner-->>InvocationHook: Return invocation result
  InvocationHook-->>AnnotateTab: Update invocation state
Loading

Possibly related PRs

  • Agenta-AI/agenta#8042: Adds the evaluation-run details page and human-run Annotate tab that this change extends.
  • Agenta-AI/agenta#8048: Adds the scenario focus drawer and invocation fields used by the updated annotate flow.
  • Agenta-AI/agenta#8102: Changes the shared annotation controller used after invocation output becomes available.
Merge Risk: Low · up to 0550f

The invocation flow has no established user-facing failure, but its new backend calls should use the required Fern client before merge.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title names the main change: running one scenario's invocation from the /m evaluation run page. The changeset adds RunInvocationPanel, useScenarioInvocation, and runScenarioInvocation, and wires a…
Description check Passed The description states the purpose (running a scenario's invocation from the hidden /m run page), the new runScenarioInvocation function, the UI states, the shared-runner fixes, the bundle-size reason…
Docstring Coverage Passed Docstring coverage is 66.67% which is sufficient. The required threshold is 60.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
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.
Full details: Title check

Explanation

The title names the main change: running one scenario's invocation from the /m evaluation run page. The changeset adds RunInvocationPanel, useScenarioInvocation, and runScenarioInvocation, and wires a Run button into the Annotate tab and annotate sheet, which matches the title.

Full details: Description check

Explanation

The description states the purpose (running a scenario's invocation from the hidden /m run page), the new runScenarioInvocation function, the UI states, the shared-runner fixes, the bundle-size reasoning, the tests, and QA steps. These all relate to the changeset.

Full details: Docstring Coverage

Explanation

Docstring coverage is 66.67% which is sufficient. The required threshold is 60.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 9 functions across 12 files.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Website preview

Preview URL: https://pr-8103-agenta-website-preview.mahmoud-637.workers.dev

Built from 0550f9c0d40bc76dc4321a280bb786a366a2a8e9. This comment updates in place on every push.

@coderabbitai coderabbitai Bot left a comment

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.

Nitpick comments: 1
web/packages/agenta-playground/src/state/evaluationRunInvocation.ts: 1

156-186: Trivial · Maintainability & Code Quality · Heavy lift

Use the Fern evaluations client for the new backend calls.

setScenarioStatus, upsertInvocationResult, and refreshMetrics call the shared axios instance with {params: {project_id}}. Frontend conventions require the Fern client for new API code. Query params go through the client's own argument shape, not {params}.

getEvaluationsClient() already exists in @agenta/sdk/resources. Import it from that subpath, not from the @agenta/sdk root. Add @agenta/sdk to web/packages/agenta-playground/package.json dependencies, using the same workspace pattern as the other entries. @agenta/entities already imports from @agenta/sdk/resources, so this does not add a new layer dependency.

Replace the three raw calls with the matching EvaluationsClient methods for the scenario patch, results upsert, and metrics refresh endpoints. Keep the try/catch around metrics refresh so a failure is still only logged. Update the axios mocks in evaluationRunInvocation.test.ts to mock the Fern client.

Source: Coding guidelines

Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 42d49f0 and 0550f9c.

Files selected for processing: 12
  • web/mobile/src/features/evaluation-run/focus/RunAnnotateBody.tsx
  • web/mobile/src/features/evaluation-run/focus/RunAnnotateSheet.tsx
  • web/mobile/src/features/evaluation-run/focus/RunAnnotateTab.tsx
  • web/mobile/src/features/evaluation-run/focus/RunInvocationPanel.tsx
  • web/mobile/src/features/evaluation-run/focus/runScenarioInvocation.ts
  • web/mobile/src/features/evaluation-run/focus/useScenarioInvocation.ts
  • web/mobile/tests/unit/runAnnotateTab.render.test.tsx
  • web/packages/agenta-playground/src/executeWorkflowRevision.ts
  • web/packages/agenta-playground/src/index.ts
  • web/packages/agenta-playground/src/state/controllers/executionItemController.ts
  • web/packages/agenta-playground/src/state/evaluationRunInvocation.ts
  • web/packages/agenta-playground/tests/unit/evaluationRunInvocation.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Item Value
Status stopped
Commit 0550f9c0d40bc76dc4321a280bb786a366a2a8e9
Manual expiry (UTC) Not granted
CI deadline (UTC) Not granted
Workflow https://github.com/Agenta-AI/agenta/actions/runs/41879752898

Dependent tests finished. Post /preview for manual review. Environment absence verified; retained storage requires separate provider accounting.

Post /preview as a new comment to request a one-hour preview. Repeating it while active does not extend the hour.
Preview data is disposable. Expiry is enforced by the next successful cleanup sweep, not an exact timer.
Environment deletion stops its compute. Provider-retained storage and permanent services may still be billed.

@mmabrouk
mmabrouk changed the base branch from main to release/v0.128.7 November 4, 2026 20:07
@mmabrouk
mmabrouk merged commit 2599de3 into release/v0.128.7 Nov 4, 2026
87 of 92 checks passed
@mmabrouk mmabrouk mentioned this pull request Nov 4, 2026
7 tasks done
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.

1 participant