mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-21 16:02:36 +00:00
* feat: eval datasets and standalone runs for reusable AI agents Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * feat: agent eval drawer with case editor, runs and capture entry points Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * docs: document AI agent eval datasets and standalone runs Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: say how many eval cases the list is not showing Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: address review findings on eval datasets - keep an edited case's conversation and tool inputs: serde(flatten) silently drops Box<RawValue> fields, so the update payload is spelled out - remount the case editor per case so one case's turns cannot leak into another - require jobs:read / flow_conversations:read on the capture endpoints, which UserDB does not gate by token scope - take the dataset lock in create and update so a delete cannot be undone by a concurrent metadata write, and delete cases before metadata - load more cases beyond the first page, and stop capping the agent picker - record that the version stamp is taken at enqueue, not at resolution Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: address round-2 review findings on eval datasets - block operators from dataset and case writes - pass the editor's operating workspace through the drawer and the capture request, instead of assuming the navigation workspace - discard superseded case-list responses so switching datasets cannot land the previous dataset's cases - reject a dataset without a case_id (or vice versa) rather than running an inline case under a dangling association - run unsaved edits inline instead of silently running the stored case - surface the API error body on a failed run - fetch dataset metadata concurrently when listing - $bindable() without a default on the optional open prop - correct the permission and enqueue-time-version wording in the docs Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: run an untouched saved case by reference again The editor writes back keys the stored case omits, so comparing the raw objects reported every unedited case as edited: the run went inline and lost the dataset/case stamp its history depends on. Compare a normalized form, and pin it with a test. Also scope the history query to the drawer's workspace and drop superseded responses. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * feat: show a dataset's cases as a table, and fix round-4 review findings The case list showed one case at a time with no overview. It is now a table with the case, where it was captured from, and its last run — the last-run column is a single jobs query on the path stamp rather than a request per row. Review fixes in the same file: - keep the edit baseline on the selected case rather than looking it up in the loaded page, so a case beyond page 1 is not treated as unedited and run stale - release the loading state when a superseded case load returns early - reload every loaded page after a write instead of collapsing to page 1 - last remaining 'resolved to' wording in the version tooltip Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * feat: run a dataset as an experiment, with scorers as runnables An experiment runs every case of a dataset against one subject and records the exact case set it executed, so a result set stays reproducible while the dataset keeps changing. Each case runs as its own small flow — the agent, then a step per scorer — so a case keeps the run stamp, history query and trajectory view a single run already has, and scorers need no orchestration of their own. Results are read back per step by node id rather than by walking a nested loop's status. A scorer is any runnable taking (input, output, expected): a script, a flow, or a reusable agent used as a judge. A judge is prompted with the case and the answer as one JSON message; a script or flow receives them as named arguments. Scores accept a bare number, a boolean or {score}. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * feat: results table for an experiment, with scorer columns One row per case: status, the agent's answer, and a column per scorer, with the mean per scorer above the table and a link into each case's run for its trajectory. Averages skip cases a scorer produced no number for — counting a missing score as zero would read as a regression. The drawer's left pane becomes Cases / Results, and Results carries the scorer picker and Run dataset. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * feat: compare an experiment against a baseline Per-scorer deltas on each row and on the mean, and a filter down to the rows that regressed. Rows join by case id, so a case added after the baseline ran has no delta instead of counting as a change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: address round-5 review findings on experiments - match scorers by label when diffing two experiments; joining by array position subtracted one scorer from another whenever the scorer sets differed - report a row's status from the case job, not the agent step, so a case whose scorer failed no longer reads as a success - delete a dataset's experiments with it: they hold copies of its cases, and a recreated dataset of the same path would have exposed them - select the experiment that Run dataset just started instead of leaving the table on the previous one - expected is scored now, so stop describing it as having no consumer Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: address round-6 review findings on experiments - hold the dataset lock across an experiment launch, so a delete landing between reading the cases and writing the experiment cannot recreate the deleted dataset's inputs - match scorers between experiments on kind and path, not on label: labels default to a path's last segment, so f/a/quality and f/b/quality compared against each other - average mean deltas over the cases both runs scored; comparing each run's own average reported a regression from a case the baseline never ran, with no regressed row to point at - openapi: the row status is the job's, which is also canceled/skipped; runEval takes scorers; the update-case body no longer advertises source, which the handler deliberately ignores - record why the experiment prefix cannot reach a sibling dataset Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: address round-7 review findings on experiments - release the dataset lock for the push loop and retake it for the write, re-checking the dataset still exists: holding it across the whole launch made every capture and case edit on that dataset 409 until the last job queued - assemble experiment results with bounded concurrency; a 100-case, 3-scorer experiment was 400 sequential lookups, each itself several queries - clear the baseline when it becomes the selected experiment, which was comparing a run against itself and reporting zero deltas - take the header mean over the same cases as its delta while comparing, so the two numbers beside each other describe the same set - a canceled or skipped case is no longer the same grey dot as a running one Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: address round-8 review findings on experiments - verify the dataset's identity, not just its existence, before recording an experiment: the path can be deleted and recreated during the push loop, and the experiment holds copies of the old dataset's cases - give the recording lock a longer budget than a case edit, since its jobs are already queued and giving up strands them, and say so when it fails - keep score lookups sequential within a case: nesting two bounded streams multiplied into 32 in-flight queries against a 50-connection pool - clear a baseline that no longer belongs to the loaded experiments, so switching datasets does not leave comparison mode on with nothing to compare - keep a scorer's own mean when the baseline never ran it, instead of blanking a column full of numbers - EvalCaseDraft.expected no longer claims nothing scores it Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: do not trust an experiment's job ids, and require write to record one Experiment objects live in workspace object storage, which a script can write directly, and results are read on the unrestricted pool — so a forged experiment naming another flow job returned output the jobs API would have refused. Only jobs this server stamped with that experiment's id are read now. Also from round 9: - recording an experiment requires write on the dataset, not read: it persists into the dataset's namespace and its shared list - clear the results table when the selection changes and surface a failed load, instead of labelling the previous experiment's numbers as the new one's - a storage fault is no longer reported as a deleted dataset - the lock-timeout message at the recording site no longer says to retry, which would run the whole dataset again on top of the jobs already queued - ExperimentRow.status documents canceled and skipped Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: bind the experiment trust check to the requested dataset The previous check matched jobs on the experiment id alone, which the stored object supplies — so copying another dataset's experiment JSON under a readable key carried its jobs' output along with it. A job is now only read if it was stamped for this experiment *and* for the dataset the caller's read access was checked against, and an experiment that names a different dataset is not served from this key at all. Also from round 10: - add the .sqlx entry for that query; without it every SQLX_OFFLINE build failed - serve results over GET: as POST the route-scope middleware classified a read as ai_evals:write, locking read-only tokens out of their own results - clear the selected and baseline experiments synchronously when the dataset changes, so the previous dataset's id is not requested under the new one Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: address round-11 review findings on experiments and scorers - give scorers the whole case input, not just the message: an answer that came from attachments or a replayed conversation could not be judged on it - accept a judge's boolean and structured {score} answers, including stringified ones, and pin every documented scorer shape with a test - record an experiment for the cases that did launch when a later push fails, instead of leaving those jobs running with nothing to attribute them to - do not capture a preview parent's synthetic runnable_path as a host flow; the saved case could not be rerun - clear the case table before loading a dataset and surface a failed load, so a failure cannot leave the previous dataset's cases under the new name - keep the results table through a refresh of the same experiment - exclude flow-step jobs from the per-case last-run lookup - drop case sets from the experiment list, which is only used to pick a run - report a database failure at the recording lock as itself, not as contention Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: address round-12 review findings on capture and run history - load flow_node.flow for flownode parents: an agent inside a deployed branch or loop captured without its agent, host flow or tool bindings - decide host_flow_path by whether the path resolves to a flow, not by job kind: excluding previews wholesale also dropped the flow editor's step test, whose path is real - page the per-case last-run lookup by created_before until the loaded cases are covered; one page of 200 reported older cases as never run - do not record an experiment when nothing launched - only attach the case input to a job when a scorer will read it - keep the case table through a save; only a different dataset clears it - drop the superseded duplicate comment on the score parser Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: stop refetching run history on every case write Reading the case list before the first await made the whole job-history query a dependency of it, so every save, delete and Load more refetched up to 1000 job rows and blanked the column. Read untracked instead. - an empty Last run cell now distinguishes never-ran from not-found-within the page bound, which the comment already claimed and the cell did not - reloading a dataset no longer replaces a populated table with a skeleton - keep the score-parser comment that describes every shape it handles Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * refactor: keep eval datasets in Postgres instead of object storage Datasets, cases and experiments become rows (`eval_dataset`, `eval_case`, `eval_experiment`, `eval_experiment_case`) rather than objects under a `wmill_eval_datasets/` prefix. What a run produced is still the job's: only case inputs and an experiment's case snapshot are stored. This removes the machinery the object store needed: - The advisory lock and the read-modify-write of a per-dataset JSONL. A case is a row, so there is nothing to serialize. - The launch-time identity check on the dataset. The foreign key makes a concurrent delete fail the transaction instead. - The trust guard on an experiment's job ids, which existed because a script can write workspace object storage directly and could forge an experiment naming somebody else's job. An experiment now chooses every job id and records itself before pushing anything, so a launch that dies partway leaves a recorded case whose job is missing rather than a running job nothing accounts for; cases that never reached the queue are removed again. Row-level security on `eval_dataset` is the authority on who may read or write a dataset, so `extra_perms` grants work and the rule is not mirrored in Rust. Cases and experiments carry a read policy derived from their dataset and no write policy: they are written on the unrestricted pool after the dataset row itself has been asked, with `SELECT ... FOR UPDATE`, whether the caller may write it. Cases are capped at 256 KiB each and 10 000 per dataset, refused rather than truncated. Attachments are S3 references, not inline bytes, so a case that approaches either cap is a mistake rather than a use case. Evals no longer need the `parquet` feature or a configured workspace object storage. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * style: align the eval drawer with the design system - Scorer chips are `Badge`s rather than a hand-rolled bordered span, and the section header is a `Label` with its tooltip, as are the case editor's fields (which also gets the label colour right). - The results table showed status as a coloured bullet, which says nothing to a colour-blind reader. It now carries the same icons the runs table uses, with the status as its accessible name. - Feedback colours move to the `-500` shades the brand guidelines name. - The conversation JSON error uses `TextInput`'s `error` prop for the border and the caption style for the message, as elsewhere. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * feat: author an expected answer, tags and attachments on a case Every scorer is handed `(input, output, expected)`, but nothing could produce an `expected` except a conversation capture: the case editor had no field for it and a captured run left it empty. So: - The editor gains Expected, Tags and a read-only list of the attachments a captured case carries. Expected is plain text, or JSON when the answer has structure. - Capturing from an AI agent run keeps what that run answered, which is the only moment a reference answer exists for free. The results table also laid itself out by content, so a long answer pushed the scores — the numbers the table exists for — off the edge of the pane. It is fixed-layout now, with the text columns bounded. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * docs: expected is captured from a run and can be authored Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * feat: link a saved agent when inserting an ai agent step "AI Agent" in the step picker was a leaf that always created a blank step, so reusing a saved agent meant inserting a blank one, opening its step input and linking it there. It is a category now, like Flow and AI Sandbox, listing the workspace's `ai_agent` resources next to a blank option, filtered by the picker's own search. A picked agent produces a step that is already linked rather than one linked afterwards: `agent` set, no tools, and only the flow-local `user_message`/`user_attachments` transforms. Seeding the brain keys there would leave transforms a linked step never reads and that `AgentResourceBar` strips on its next link change. Each `on:new` forwarder rebuilds the insert detail field by field instead of spreading it, so a new field is dropped unless the forwarder names it. `agentPath` is typed on both `GraphEventHandlers.insert` and `FlowGraphV2`'s `onInsert` so the next one to forget it fails the check. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * feat: restore the link on cancel and simplify the agent bar Cancel on an agent edit forked the step into a standalone copy, which is the opposite of what the word means and needed a paragraph under the card to explain. It discards the edits and re-links the step now, leaving the agent untouched; diverging from an agent is Unlink's job, on the linked card. This flow's `tool_inputs` survive the round trip as overrides, so Cancel no longer folds them into the tools the way Unlink does. Linking a step to a saved agent happens in the step picker at insert time, so the bar's own resource picker is gone and "Save as agent" is the one action left. Its `+` button was a trap besides: it opened the generic resource form, where an agent would have to be written as raw JSON. The card itself was `surface-secondary`, the sections token, so in dark mode it was darker than the pane and read as a sunken well rather than an elevated card. It uses `surface-tertiary` as the brand table prescribes, its tool chips are `Badge`s, and the editing card no longer overflows the pane and clips its own buttons. The remaining tooltip follows the inline `Label` convention rather than sitting in a flex row whose gap stacked on the trigger's own margin. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * feat: rework the AI agent evals surface into one table Evals become a single pane: a dataset of cases, one column per scorer, one row per case, with the run being looked at chosen from the toolbar. Runs are permanent. Running the whole dataset opens one; running a single case records nothing at all — it is a job, and looking at what it did is not a claim that it belongs in the history. Its result and its scores sit over the row until they are saved as a run, which carries the cases that were not rerun and the scoring jobs themselves, so the number that is saved is the number that was looked at. A scorer is a runnable: a judge agent or a script, created in one click and edited in place. Scores carry a reason and per-assertion checks, shown on hover with a rescore button. What ran is always named. A run records the agent version, or — for a configuration that is not deployed — a hash of it, so a table can say that its numbers describe an agent that no longer exists: those rows dim and the table offers to rerun. An agent's draft can be run directly instead of the deployed value, and once those edits are deployed the runs that made them are recognised as that version. A step with no agent of its own is evaluable too, and saving it as an agent moves its history onto it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * feat: keep an agent's in-progress edits on the agent Editing a linked agent forks it into the step, which is what makes the edits runnable there — but the agent is what is being edited, so that is where the unsaved state belongs. The edit is mirrored into the agent's own resource draft as it is made. It then survives leaving the flow, shows the agent as drafted wherever it appears, and is what evals run when asked to run the draft rather than what is deployed. Deploying or cancelling clears it; opening Edit without changing anything does not mark the agent as drafted. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * feat: shape the evals surface around a saved agent Evals hang off an `ai_agent` resource, so the surface is now only ever about one: the `draft` subject kind, the standalone-step subject and the move that carried a step's history onto a newly saved agent are gone. - A run is permanent and numbered per agent. Running a single case is a trial: it answers in the panel and never touches the table. - "Run scorers only" opens a run of its own that reuses the answers of the run you are looking at, so a scorer added later measures what already ran without calling the agent again. - A draft run whose configuration is later deployed is stamped, once, to the version it became, so its label stops reading `v23 + edits` forever. - A scorer can carry a pass threshold, read off the scores already recorded. - The table is the case, its answer and one number per scorer; datasets are created and edited in a drawer; a run that executed an earlier state of the current draft says so above the table, in one line. - Which agent a step is, whether it is being edited, and which version it is on is a strip above the step's tabs, because it is true of every tab. - Capturing a case from a step test or a conversation is dropped, and with it the `memory` override on a linked step that nothing set. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * feat: run past versions of an agent, and number versions per resource The evals home becomes one table of every run of the agent, whichever dataset each is of, with one badge per scorer. A list spanning datasets cannot hold every dataset's scorers to look a name up, so a score carries its name and kind with its number, and thresholds are joined in per run and column. Run now asks what to run: the latest agent, resolved when the run executes as a flow step does, any past version, or the unsaved edits. Pinning is a subject kind of its own, since a linked step resolves the resource live and inlining is the only way to run a version that is no longer current. Scorers move into the edit-dataset drawer. The column header over a run reports and nothing else: a run is permanent, and a control there that changed the columns would edit the past from the one place that must not. Adding one offers four ways rather than two, writing and reusing being different jobs, and both new kinds open with a summary filled in. Versions are numbered per resource. `resource_version.id` is one identity sequence for the whole table, so an agent saved nine times read v4 ... v24, and the gaps counted writes in workspaces the reader cannot see. The id stays how a version is addressed; the new number is what it is called, in the resource history drawer as well as here. It is assigned on write rather than counted on read because trimming past the cap and clearing a history both take the oldest rows, and counting the survivors would renumber a version a run already names. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix: read the dataset a remembered selection names Reopening the evals modal restored the last dataset from storage as a bare path, without reading the row it names. Every "is this already the one?" test compared against that selection, so all of them short-circuited and the dataset was never loaded: editing it opened a drawer with no summary, no scorers and no cases. The remembered path is now brought into context the same way any other choice is, and the tests compare against the dataset that is loaded rather than the one that is selected, so a selection can no longer stand for a read that did not happen. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * feat: give dialogs a trail in their header A dialog deep enough to navigate had nowhere to say where you were: the header held a fixed title, and the way back was a control each body placed for itself, somewhere in a toolbar that moves with everything else the toolbar holds. The header is the one part of the surface that does not move, which is where the trail belongs. `Modal` takes an optional `trail` of levels below its title, rendered as a breadcrumb whose ancestors are the way back. Declarative on purpose: callers of this depth already hold the state that says where they are, so the dialog reads it rather than owning a stack they would have to push and pop in step with it. Escape follows the trail. Leaving a level is what someone deep in a dialog means by it, and closing the whole surface throws away the navigating they did to get there; at the root it closes as before. That only works if a dialog can tell it is the surface being addressed, so `Disposable` now answers `isTopmost()` and the dialog asks before acting: it keeps Escape for itself, so nothing else was arbitrating between it and a drawer opened from inside it, and both were acting on one key press. Evals is the first caller: its runs list is the root, a run is a level in it, and the back button that used to sit above the table is gone. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix: portal dialogs out of wherever they were opened from A dialog rendered in place inherits whatever the calling component happens to sit inside. One `transform`, `filter` or `overflow` anywhere above it makes its `fixed` positioning resolve against that ancestor instead of the viewport, and a surface meant to cover the app is then confined to a box it never asked for: the nav rail paints over it and its own edges are clipped. Drawers have always portalled for this reason. Dialogs only did so when an enclosing pane claimed them, and rendered in place otherwise, so the same screen could show a drawer over everything and a dialog trapped behind the nav. They now portal the same way: to the pane when one claims it, to `body` otherwise. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix: make the dialog's title the first step of its trail The trail listed levels below the title, so a dialog one level deep read "Evals > All runs > Run 20 · v6": three steps for two places, the first two of them the same place under different names. The title is the root, so it is the root's own segment, and the trail a dialog is given is now the whole path with that segment at its head. Its height stopped moving too. A heading carries a line-height of its own, so a header holding only an h3 stood six pixels shorter than one holding segments as well, and the dialog's whole top edge stepped as you navigated. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix: sharpen the evals controls around where you are standing Each screen now offers what belongs to it. The list starts runs; a run is a record, so it offers only the one thing that acts on the record itself, which is measuring the answers it already stored. Starting a fresh run from inside one asked which agent and which dataset from the screen least about either, and scoring an existing run was offered from the list, where there is no run to score. Which run and what it is read against are one question asked twice, so they sit together rather than at opposite ends of a row. Choosing what to run is now a toggle over the two states worth naming, the draft and the saved agent, with every earlier version one click further: running an old version is deliberate, and a list made all three look alike. The draft is read when the dialog opens rather than taken from the caller's polled copy, which could be seconds behind an agent edited a moment ago and would leave the option out exactly when it is the reason for opening the dialog. The dataset field carries its path under it and its edit button on hover, as a resource picker does, so the closed field says what the open list said. Edits waiting on an agent are a "draft" here as everywhere else in Windmill, rather than "+ edits". The dialog runs an evaluation rather than "the agent", which is what it was already called everywhere it is recorded. An agent being edited keeps its evals button on a line of its own, clear of the decision to save or discard. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix: settle the evals controls on the patterns Windmill already has The version choice uses ToggleButtonMore, as the AI provider picker does: the two states worth naming stay in the group, the rest are behind the overflow menu, and the one you pick joins the group rather than appearing in a second control below it. The deployed one says which version it resolves to. A run offers nothing to start. Scoring an existing run again was the last thing left there, and it was one button explaining a distinction that the run and the dataset already make between them. The warning that a run executed an earlier draft is about the run on screen, so it goes when the run does rather than following you back to the list, and it sits against the table instead of inside a frame of its own. A dataset just created stays open for its scorers and cases: those are what a dataset is, they can only be added to one that exists, and closing on create sent you to find it again to add them. Scorer settings are a cog rather than a word, now that the row holds three actions. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix: close the gap in the version toggle and say what naming a dataset does The overflow trigger is not a pill, so the room it reserves showed as a gap between it and the button before it; it is pulled in by that much. The dataset field gets its clear button, which is also the slot the edit button is positioned against, so the two now sit where a resource picker puts them. Naming a new dataset said nothing about what happens next, and the drawer looked like it was missing the rest of itself. It says so instead: a scorer and a case both belong to a dataset, so there is nothing to attach either to until this one exists, and creating it leaves the drawer open on them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * feat: choose a dataset's scorers while naming it A scorer is a reference to a runnable, not a child of the dataset, so it needs the dataset's name but not its row. The list is collected in the drawer while the dataset is being named and sent with the create, which already accepts one, so a dataset arrives holding the columns that were chosen for it rather than being made empty and then edited to hold them. Cases stay where they were: a case *is* a row of the dataset, so there is nothing for it to be a row of until one exists. The drawer says which of the two is which instead of leaving the screen looking like it is missing the rest of itself. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix: level the version toggle and name the dataset in its own field The overflow trigger stands a row taller than a toggle button, so the group grew to its height and left the sunken background showing under every pill beside it. Every child of the group is the same height now, which is why the AI provider picker never had the band: it sizes them all alike. The dataset field says the summary with the path after it rather than carrying the path on a line below. The list stacks the two, which a one-line field cannot do, so it says both the other way round. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix: tidy the evals forms and the run's own controls Picking a scorer that exists chooses between two sources rather than showing both: the ones already measuring something, and everything else in the workspace. The first list says what each is called with its path under it and what it already measures on the right, instead of three columns that were the same path truncated three ways whenever a scorer had no name of its own. A dataset's drawer says what it is for on the page rather than under an icon, and its summary is sized like the field beneath it. The run's own row lines up with the table under it, the warning above that table is spaced off the rule rather than sitting on it, and adding a case is gone from a run: a run is a record of cases that were answered, so curating them from it is editing what it measured. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * feat: create a dataset holding the cases written for it Creating a dataset takes the cases to create it with, so one can be assembled in a single act instead of made empty and then filled in. The drawer holds them while the dataset is being named, gives them ids of its own to be edited by, and sends them with the create. Every case is checked before the dataset is written. `eval_case` grants users no write, so the rows cannot be inserted in the transaction that creates the dataset under the caller's own policies; validating first is what keeps "created holding these cases" from becoming "created, holding some of them", and the rows that do follow go in one transaction of their own. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix: name the button for what it opens, and say what each version is Starting an evaluation asks which state of the agent and which dataset, and both cost a provider bill, so a button that read as spending one on the way past was lying about the click. It opens something, and says so. Running one case from the panel keeps its own name and its play icon, because that one does run on click. The version options say what they are rather than what they are not: what a flow step would or would not run is a fact about somewhere else, and someone choosing what to evaluate is not standing in it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix: give the editing card two rows and mark evals as beta At the width of a step panel the card's one row wrapped: the line naming the agent, the line saying what saving does, and the two buttons deciding the edits' fate all fought for it. Deciding gets a row of its own, and evals sits against the line it is about, since evals of an agent being edited run the edits. Evals is named wherever it is offered. It read as a word in one state of the card and as an icon in the other, which is two things to recognise for one door. The dialog carries a beta badge against its own name, before any level below it: every way in lands there, so it is said once and stays put as you navigate. The version toggle spells out which is which. Both are the agent at v2 and the difference between them is the whole choice, so it is worth the width. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix: name a new dataset, and lay the scorer's settings out like a step's inputs A new dataset arrives called "Dataset 1", which the path follows as it follows any summary: a dataset with none was one every table could only call by its path, and the two seeds are what the summary rule already produces. Scorer settings put each field's description between its label and its input, where a step's inputs put theirs, and its inputs are the size the rest of the drawer uses. The runnable behind the column is a link to it with its kind's icon, since it is a resource of its own and the one thing about it these fields cannot change. The line explaining that a pass line re-reads recorded scores went: the threshold is a number to set, and how it is applied is not a decision being made here. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * feat: curate a dataset in the drawer and save it in one act The drawer holds the cases while they are edited and writes them when it is saved: added, changed and dropped, whichever it is. Typing no longer writes, so a set is never half saved while someone is still deciding what is in it, and Save means the same thing whether the dataset exists yet or not. A case panel offers reading rather than acting. Running one case now and editing one from a run were the last two ways to change a record from the screen showing it, and the machinery behind the first went with it. The answer is rendered as the prose it is, under what it is: the case's result, whichever run is selected above it. The rest is what the run's table was doing to its own edges: a column name is clipped to its column rather than running into the next, the table squares off against an open panel, and that panel closes with the run it belonged to. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix: one border above a table, and a link to the run's job The row above the table drew a bottom border and the table draws its own top edge, so every table sat under two lines. The row keeps its spacing and the table keeps its edge. A column header no longer spins while its scores arrive: the cells under it are where the numbers are missing, and they say so themselves. The beta badge is the height of the word beside it rather than of the line it sits on. A run is one flow and therefore one job, so the run says where that job is: what it is doing, what it cost and what it logged are all there rather than reconstructed from the table. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * feat: stream scores as each scorer finishes, and show them per case A scorer runs after the agent inside the case's own iteration, so its verdict can be read as soon as its step is done. Waiting for the iteration to end held every column of a case back until the last of them finished, which is why answers arrived one at a time and scores all at once. Reading a job that is still running needs one guard: a module with nothing in it is a step that has not run, not one that produced nothing, and recording the second makes a failure that never goes away. The panel beside the table shows what each column made of the case and why. The reason a judge gave was stored and never shown, which is the half of a score that says anything. It stops repeating the question the header already asks, and a case still running reads as waiting rather than as an answer that says "Running". A run is a number beside a dataset, so the list puts the two together. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * feat: score a case with every scorer at once The scorers of a case read the answer and never each other, so they ran one after another for no reason: measuring a case now takes as long as its slowest column rather than as long as all of them. Each is a branch of its own, kept from failing the others, so a judge that errors costs its own column and no more. An iteration is three steps again — answer, payload, scores — rather than one per scorer, and each branch is named for the column it produces, so the graph of a run says which scorer did what instead of spelling out an id. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix: read a judge's score out of the JSON it nearly wrote A judge quoting the agent inside its own reason writes those quotes unescaped, which is invalid JSON and also the most ordinary sentence for it to produce. The whole verdict was being thrown away over it, so a column that had a number reported having none. The number and the reason are now read straight out of such text. Deliberately not a second JSON parser: it finds the two keys and takes what follows, which is what survives a quote in the middle of a sentence. A case still running says so with a spinner rather than with the word "Running" sitting where its answer goes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * feat: ask a judge for a shape instead of trusting it to write one A new judge carries an output schema, so the provider holds it to `{score, reason}` rather than the prompt asking it to. Windmill already delivers a schema whichever way the model takes it, a tool for Claude and Bedrock and the native parameter elsewhere, so there is no list of models to keep here. An agent with no runs offers its first one where the first row would be, rather than from a toolbar above a table that has nothing in it. Starting a run no longer picks a dataset for you. It fell back to whichever came first, which on an agent that has never run means offering another agent's set as though it were the obvious one; and with no dataset at all it says so and offers the one move there is. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * feat: report a column that failed throughout, and hold the run dialog The runs overview dropped any column that produced no number, so a judge that failed on every case of a run vanished from the row and read as a column nobody had asked for. The aggregate now reports every column that has cells, with the count of the ones it failed on, and the badge says "failed" where there is nothing to average. A column with no cells at all is still left out: that one was added after the run and has nothing to say about it. Creating a dataset closes the drawer rather than turning it into an edit of what it just made: scorers and cases already ship with the create, so there is nothing left to stay open for. Reached from the run dialog, it gives the screen back with the new dataset selected, and the dialog keeps the version you had already chosen. Also: - the case panel's job link moves to the panel's own header, where its scope is: the job is the whole iteration, not the answer it sat over - one action in the scorer drawer's header, as its neighbours have. The reuse list picks rather than adds, and says which dataset each column already measures - adding a case is the last row of the list it lands in - the pane shows what it has read rather than an empty state it has not earned yet, and its rows say they open - the linked agent card loses a border it had inside another one * fix: keep the linked agent card's outline The card is a thing inside the step's inputs rather than a section of them, and the outline is what says so. Only the rule inside it goes: the detail it separates is already set apart by being detail. * refactor: fit the eval surface to the shipped design * feat: give a nested dialog a back control and the runs list its own moves Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat: put a dialog's description under its title Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * refactor: fold a dialog's back control into the crumb it returns to Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat: edit a dataset's cases as a table rather than a list beside a form Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat: edit a dataset's cases in the grid the data tables are edited in Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat: edit a grid cell of prose in place, and cap a dataset at one page Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * refactor: keep the cell editor's styles beside it, not in the vendored theme Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: keep an empty cell empty and cap the editor's growth Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat: name the step that assembles a run for the scorers Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat: run the payload step natively, and say so when nothing serves that tag Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: report an answer as answered while its scorers are still running Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat: let a scorer say a case is not one it measures Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: score the answer, and leave a case with no expected answer unmeasured Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * refactor: split the evals backend into modules Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: record what a run produced so it outlives its jobs * fix: read only the agent step's own tool jobs into the payload * fix: pin a run's configuration and give the judge the attachments * feat: write a dataset's cases in one transaction * chore: refresh the sqlx cache for the eval queries * fix: drop results a newer selection has superseded * fix: keep a draft the agent editor never opened on * feat: let a run record what it produced instead of waiting to be read * fix: serialize the replacements of a dataset's cases * fix: stop the poller from superseding a read slower than its interval * chore: refresh the sqlx cache * fix: keep a failed read from settling a cell as a case with no answer * fix: hold the case grid while its save is in flight * fix: keep a failed collect step from failing the run it recorded * chore: refresh the sqlx cache * fix: commit an open cell into the save that reads it * refactor: size the eval buttons with unifiedSize * docs: describe a run as the one flow it is * fix: show a run's recorded rows when part of it cannot be collected * refactor: size the remaining PR-added buttons with unifiedSize * fix: save the dataset name that was submitted, not the one typed after * fix: force an open cell into the save that was pressed for it * fix: refuse to score a run whose evidence could not be read * fix: hold one lock over a dataset's case count and its writes * fix: keep one unreadable run from costing the whole runs list * refactor: drop the banned bindable-default from the eval props * fix: hold the scorer controls while the dataset is written * fix: read only the caller's own draft of an agent * docs: say in the contract that a run pins its configuration * fix: say a scorer did not run rather than blaming a missing answer * feat: resume the agent draft you already had when you press Edit * refactor: build the trail and dataset controls from Button * fix: clear the open-cell flag when the drawer reopens * chore: refresh the sqlx cache * fix: read a run's configuration and its version from one snapshot * fix: refuse a dataset path or summary the column cannot hold * refactor: handle the agent draft the way the resource editor does * fix: run only a configuration the launch actually read * docs: bound dataset path and summary where they are submitted * fix: surface a stalled agent draft instead of claiming it is kept * fix: stop claiming a draft holds edits a failed write never sent * fix: word a missing score only once the run says whether the case answered * fix: let a breadcrumb crumb shrink so its truncation applies * docs: describe where an agent's unsaved edits live and what drops them * fix: keep harvesting scores when the run cannot yet word a missing one * fix: report a refused draft write the card was reading as a save * fix: drop the refused draft write when the server copy is taken instead * refactor: build the scorer and dataset pickers from the design system * fix: say what removing a scorer column actually does * fix: drop a refused draft write wherever the server copy is read * fix: let a picker row be as tall as the two lines it holds * docs: record what removing a scorer column does to recorded runs * fix: send a queued draft write before reopening, and drop only what it refuses * refactor: write the agent draft at commit points instead of mirroring keystrokes Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * refactor: run an agent's edits from the step instead of keeping them as a draft Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: make the diff badge keyboard operable and refuse an edits run without its edits Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: drop the dataset icon from the scorer picker rows Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: size the evals buttons like the rest of windmill and call a run of edits edits Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: count a brain expression as an edit of the linked agent * fix: cap scorers per dataset and report a launched run as launched * fix: harvest scores in one read, refuse duplicate case ids, allow group paths * fix: mint scorer ids server-side, save a dataset edit in one request, check attachments * fix: write a dataset edit and its cases in one transaction * fix: atomic dataset create/edit, reset eval pane per agent, stable pending scorer ids * refactor: govern eval_case writes by RLS so a dataset edit is one transaction * fix: pin launch snapshot, order case locks, cap dataset size, guard stale load * fix: cap dataset bytes on single-case writes, reset run-dialog flag on load failure * feat: migrate eval datasets on username change, settle unspawned cases, drop unused case endpoints * fix: resolve scorer scripts as the caller and pin their hash; migrate scorer paths on rename * fix: bound a failed tool call's error to the payload truncation cap * fix: pin scorer hash as a hex string, reject missing judges, migrate eval authorship * fix: record an out-of-range scorer result as an error, not a score * fix: resolve judges in one caller-scoped read, pin deployed scripts, bound pass_if * fix: settle unspawned cases only when the run completes, and their score cells too * feat: reassign eval datasets and their path references when offboarding a user * fix: use the regex backreference in offboarding eval path rewrites * fix: register eval datasets in offboarding registries, keep resource-version param name * refactor: name the resource-version path param id, since it is the row id not the version * fix: validate dataset paths canonically, clone eval data on fork, surface eval load and launch failures * docs: note MCP tool results are not yet surfaced to eval scorers * fix: show the eval error state on any load failure, not only an empty dataset list * fix: preserve eval case order across a batched save Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LVjewUvXFEjNLLw7kxz41h * docs: scope the eval launch delete-safety guarantee to the assembly window Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LVjewUvXFEjNLLw7kxz41h * fix: only offer deployed scripts as eval scorers, drop unbuilt rescore claim Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LVjewUvXFEjNLLw7kxz41h * fix: enforce 0-1 scorer threshold in the settings drawer and clear stale eval load errors Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LVjewUvXFEjNLLw7kxz41h * fix: scope subject version/hash reads to the caller and keep a 0 pass threshold Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LVjewUvXFEjNLLw7kxz41h * fix: select the saved dataset when creating or renaming from the Run dialog Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LVjewUvXFEjNLLw7kxz41h * fix: gate eval dataset rename on path ownership, not just write access Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LVjewUvXFEjNLLw7kxz41h * fix: tolerate a malformed agent config when resolving the deployed label Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LVjewUvXFEjNLLw7kxz41h * refactor: trim eval code and comments, fix shared select and modal paths Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: drop the rename warning when editing an eval dataset path Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: add eval dataset delete, keep summary on partial edits, settle resultless scorer cells Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * test: cover parseThreshold and subjectLabel Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: hold dataset Save during a scorer write, derive draft_hash only from the carried draft Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
713 lines
30 KiB
Rust
713 lines
30 KiB
Rust
use super::*;
|
||
|
||
/// What a scorer resolves to, alongside the definition to record: a script by its pinned hash, or
|
||
/// a judge by the configuration to inline.
|
||
pub(crate) enum ResolvedScorer {
|
||
Script { hash: i64 },
|
||
Judge { config: AgentDraft },
|
||
}
|
||
|
||
/// The runnable a scorer names, resolved through the caller's *own* database so a run can only
|
||
/// execute code the caller may read: a scorer is added with a bare path and nothing checks read
|
||
/// access there.
|
||
///
|
||
/// Returns the definition to record and what to run: a script by its deployed hash to pin, or a
|
||
/// judge by the configuration to inline, so a redeploy midway through a run cannot swap the code
|
||
/// out from under a score labelled with the old version.
|
||
pub(crate) async fn resolve_scorer(
|
||
user_db: &UserDB,
|
||
authed: &ApiAuthed,
|
||
w_id: &str,
|
||
scorer: &Scorer,
|
||
) -> Result<(String, ResolvedScorer)> {
|
||
match &scorer.def {
|
||
ScorerDef::Script { path } => {
|
||
// The latest *deployed* hash (no draft, no failed deploy), through the canonical helper
|
||
// so the version a scorer pins is the one everything else runs.
|
||
let mut tx = user_db.clone().begin(authed).await?;
|
||
let hash = windmill_common::get_latest_script_hash(&mut *tx, path, w_id).await?;
|
||
tx.commit().await?;
|
||
let Some(hash) = hash else {
|
||
return Err(Error::BadRequest(format!(
|
||
"Scorer script {} is not deployed or not readable",
|
||
path
|
||
)));
|
||
};
|
||
Ok((
|
||
scorer.definition(Some(&hash.to_string())),
|
||
ResolvedScorer::Script { hash },
|
||
))
|
||
}
|
||
ScorerDef::Agent { path } => {
|
||
let Some((config, version)) = readable_agent_state(authed, user_db, w_id, path).await?
|
||
else {
|
||
return Err(Error::BadRequest(format!(
|
||
"Judge scorer {} is not a readable ai_agent resource",
|
||
path
|
||
)));
|
||
};
|
||
Ok((
|
||
scorer.definition(Some(&version.to_string())),
|
||
ResolvedScorer::Judge { config },
|
||
))
|
||
}
|
||
}
|
||
}
|
||
|
||
/// Bring a run's record up to date with the flow that executed it: which iteration answered which
|
||
/// case, what the agent answered, and what its scorers returned.
|
||
///
|
||
/// `answers` is what separates the two callers: a listing reports each run's score aggregates and
|
||
/// never shows an answer, so harvesting them there reads a column of every case of every listed
|
||
/// run to display none of it.
|
||
pub(crate) async fn sync_run(
|
||
db: &DB,
|
||
w_id: &str,
|
||
experiment_id: Uuid,
|
||
run_job_id: Uuid,
|
||
answers: bool,
|
||
) -> Result<()> {
|
||
backfill_case_jobs(db, w_id, experiment_id, run_job_id).await?;
|
||
settle_unspawned_cases(db, w_id, experiment_id, run_job_id).await?;
|
||
if answers {
|
||
record_case_answers(db, w_id, experiment_id).await?;
|
||
}
|
||
harvest_flow_scores(db, w_id, experiment_id).await?;
|
||
Ok(())
|
||
}
|
||
|
||
/// Give a terminal status to cases the run never spawned an iteration for: with no `job_id` there
|
||
/// is nothing to read an answer or a score out of, so they would report "running" indefinitely.
|
||
async fn settle_unspawned_cases(
|
||
db: &DB,
|
||
w_id: &str,
|
||
experiment_id: Uuid,
|
||
run_job_id: Uuid,
|
||
) -> Result<()> {
|
||
// Only a run that has reached `v2_job_completed` is settled from here. A job absent from the
|
||
// tables is as likely mid-launch — the experiment is committed before its job is pushed — as
|
||
// aged out, and settling then would cancel the cases of a run about to start. A cancelled run
|
||
// lands in `v2_job_completed`, so a cancel before an iteration spawned is still covered.
|
||
let Some(terminal_status) = sqlx::query_scalar!(
|
||
"SELECT status::text AS \"status!\" FROM v2_job_completed WHERE id = $1 AND workspace_id = $2",
|
||
run_job_id,
|
||
w_id
|
||
)
|
||
.fetch_optional(db)
|
||
.await?
|
||
else {
|
||
return Ok(());
|
||
};
|
||
let settled = sqlx::query_scalar!(
|
||
"UPDATE eval_experiment_case SET status = $2, answered = false
|
||
WHERE experiment_id = $1 AND job_id IS NULL AND status IS NULL
|
||
RETURNING ordinal",
|
||
experiment_id,
|
||
terminal_status
|
||
)
|
||
.fetch_all(db)
|
||
.await?;
|
||
// The score cells of a case that never ran have no job to read a verdict out of either.
|
||
if !settled.is_empty() {
|
||
sqlx::query!(
|
||
"UPDATE eval_score SET error = 'The case did not run'
|
||
WHERE experiment_id = $1 AND ordinal = ANY($2)
|
||
AND score IS NULL AND error IS NULL AND NOT not_applicable",
|
||
experiment_id,
|
||
&settled
|
||
)
|
||
.execute(db)
|
||
.await?;
|
||
}
|
||
Ok(())
|
||
}
|
||
|
||
/// In-flight reads of what a case's agent step produced. Each is several queries and a run holds
|
||
/// up to `MAX_CASES_PER_DATASET` cases, so they go a few at a time.
|
||
const HARVEST_CONCURRENCY: usize = 8;
|
||
|
||
/// Cases whose scorer results are read in one query: every scorer of every case in the batch, so
|
||
/// the batch bounds how much of a run's worth of judge conversations is held at once.
|
||
const HARVEST_BATCH_CASES: usize = 100;
|
||
|
||
/// Copy what each iteration produced into its row: the agent's answer, whether producing it
|
||
/// succeeded, and how the iteration ended.
|
||
///
|
||
/// Written once, when it becomes readable, rather than read back out of the jobs whenever the
|
||
/// table is displayed — jobs have their own retention, and a run whose rows are kept has to still
|
||
/// read as the run it was after they have aged out.
|
||
async fn record_case_answers(db: &DB, w_id: &str, experiment_id: Uuid) -> Result<()> {
|
||
let unrecorded = sqlx::query!(
|
||
"SELECT c.ordinal, c.job_id AS \"job_id!\", d.status::text AS status,
|
||
(j.id IS NOT NULL) AS \"job_exists!\"
|
||
FROM eval_experiment_case c
|
||
LEFT JOIN v2_job j ON j.id = c.job_id AND j.workspace_id = $2
|
||
LEFT JOIN v2_job_completed d ON d.id = c.job_id AND d.workspace_id = $2
|
||
WHERE c.experiment_id = $1 AND c.job_id IS NOT NULL AND c.status IS NULL",
|
||
experiment_id,
|
||
w_id
|
||
)
|
||
.fetch_all(db)
|
||
.await?;
|
||
|
||
use futures::StreamExt;
|
||
let answers = futures::stream::iter(unrecorded.into_iter().map(|row| async move {
|
||
// The job was retained away before anything read it: nothing to read, and nothing more
|
||
// will ever be there to read.
|
||
if !row.job_exists {
|
||
return Ok((row.ordinal, None, None, Some("unavailable".to_string())));
|
||
}
|
||
// The agent step's own result, never the iteration's: the iteration goes on to score the
|
||
// answer, so the answer is settled long before the iteration is.
|
||
let agent = agent_result(db, w_id, row.job_id).await?;
|
||
// An iteration that ended without an answer — skipped, cancelled, or an agent that failed
|
||
// outright — produced none, and saying so is what stops this re-reading it.
|
||
let answered = agent
|
||
.as_ref()
|
||
.map(|(_, success)| *success)
|
||
.or_else(|| row.status.is_some().then_some(false));
|
||
let output = agent.as_ref().and_then(|(result, _)| agent_answer(result));
|
||
Ok::<_, Error>((row.ordinal, output, answered, row.status))
|
||
}))
|
||
.buffered(HARVEST_CONCURRENCY)
|
||
.collect::<Vec<_>>()
|
||
.await
|
||
.into_iter()
|
||
.collect::<Result<Vec<_>>>()?;
|
||
|
||
// One statement for the whole run: the run's own collect step reaches every case at once, and
|
||
// a thousand of them one at a time is a thousand round trips.
|
||
let mut ordinals = vec![];
|
||
let mut outputs = vec![];
|
||
let mut answered = vec![];
|
||
let mut statuses = vec![];
|
||
for (ordinal, output, was_answered, status) in answers {
|
||
// Nothing to record yet, and the iteration may still produce it.
|
||
if was_answered.is_none() && status.is_none() {
|
||
continue;
|
||
}
|
||
ordinals.push(ordinal);
|
||
outputs.push(output);
|
||
answered.push(was_answered);
|
||
statuses.push(status);
|
||
}
|
||
if ordinals.is_empty() {
|
||
return Ok(());
|
||
}
|
||
sqlx::query!(
|
||
"UPDATE eval_experiment_case c
|
||
SET output = COALESCE(c.output, t.output), answered = COALESCE(c.answered, t.answered),
|
||
status = COALESCE(c.status, t.status)
|
||
FROM UNNEST($2::int[], $3::text[], $4::bool[], $5::text[])
|
||
AS t(ordinal, output, answered, status)
|
||
WHERE c.experiment_id = $1 AND c.ordinal = t.ordinal",
|
||
experiment_id,
|
||
&ordinals,
|
||
&outputs as &[Option<String>],
|
||
&answered as &[Option<bool>],
|
||
&statuses as &[Option<String>],
|
||
)
|
||
.execute(db)
|
||
.await?;
|
||
Ok(())
|
||
}
|
||
|
||
/// The agent step's result, with "there is none" kept apart from "it could not be read": a lookup
|
||
/// that failed for any other reason must not be recorded as a case that produced no answer,
|
||
/// because nothing reads that row again.
|
||
pub(crate) async fn agent_result(
|
||
db: &DB,
|
||
w_id: &str,
|
||
job_id: Uuid,
|
||
) -> Result<Option<(Box<RawValue>, bool)>> {
|
||
match windmill_queue::get_result_and_success_by_id_from_flow(
|
||
db,
|
||
w_id,
|
||
&job_id,
|
||
AGENT_NODE_ID,
|
||
None,
|
||
)
|
||
.await
|
||
{
|
||
Ok(found) => Ok(Some(found)),
|
||
Err(Error::NotFound(_)) => Ok(None),
|
||
Err(e) => Err(e),
|
||
}
|
||
}
|
||
|
||
/// Match each case to the iteration that ran it. The flow engine mints those job ids, so the case
|
||
/// they belong to is read back from the iteration's own arguments, which survives iterations
|
||
/// finishing in any order.
|
||
async fn backfill_case_jobs(
|
||
db: &DB,
|
||
w_id: &str,
|
||
experiment_id: Uuid,
|
||
run_job_id: Uuid,
|
||
) -> Result<()> {
|
||
sqlx::query!(
|
||
"UPDATE eval_experiment_case c SET job_id = j.id
|
||
FROM v2_job j
|
||
WHERE j.parent_job = $3 AND j.workspace_id = $2
|
||
AND (j.args -> 'iter' -> 'value' ->> 'case_id')::uuid = c.case_id
|
||
AND c.experiment_id = $1 AND c.job_id IS NULL",
|
||
experiment_id,
|
||
w_id,
|
||
run_job_id
|
||
)
|
||
.execute(db)
|
||
.await?;
|
||
Ok(())
|
||
}
|
||
|
||
/// Read the scores a run's own flow produced into `eval_score`, so a score outlives the flow
|
||
/// that produced it and the retention on its jobs.
|
||
async fn harvest_flow_scores(db: &DB, w_id: &str, experiment_id: Uuid) -> Result<()> {
|
||
let pending = sqlx::query!(
|
||
// Left-joined, so an iteration still running is read too: a scorer runs after the agent
|
||
// within that iteration, so its verdict is there to be read as soon as its own step is
|
||
// done, and waiting for the iteration to end would hold every column of a case back until
|
||
// the last of them finished.
|
||
"SELECT s.ordinal, s.scorer_id, c.job_id AS \"job_id!\", d.status::text AS status,
|
||
c.answered, (j.id IS NOT NULL) AS \"job_exists!\"
|
||
FROM eval_score s
|
||
JOIN eval_experiment_case c
|
||
ON c.experiment_id = s.experiment_id AND c.ordinal = s.ordinal
|
||
LEFT JOIN v2_job j ON j.id = c.job_id AND j.workspace_id = $2
|
||
LEFT JOIN v2_job_completed d ON d.id = c.job_id AND d.workspace_id = $2
|
||
WHERE s.experiment_id = $1 AND s.score IS NULL AND s.error IS NULL
|
||
AND NOT s.not_applicable AND c.job_id IS NOT NULL",
|
||
experiment_id,
|
||
w_id
|
||
)
|
||
.fetch_all(db)
|
||
.await?;
|
||
if pending.is_empty() {
|
||
return Ok(());
|
||
}
|
||
|
||
// The job tree is walked in SQL rather than once per cell: a live run is read every couple of
|
||
// seconds and a full one is up to MAX_CASES_PER_DATASET × MAX_SCORERS_PER_DATASET cells. The
|
||
// shape is `build_run_flow`'s: a scorer is the one module of its own branch of the scoring
|
||
// step, so its job's parent is that branch and the branch's parent is the case.
|
||
let mut case_jobs: Vec<Uuid> = pending.iter().map(|row| row.job_id).collect();
|
||
case_jobs.sort();
|
||
case_jobs.dedup();
|
||
let mut modules: Vec<String> = pending
|
||
.iter()
|
||
.map(|row| scorer_module_id(&row.scorer_id))
|
||
.collect();
|
||
modules.sort();
|
||
modules.dedup();
|
||
let mut verdicts: Vec<(i32, String, Option<(Verdict, Option<String>)>)> =
|
||
Vec::with_capacity(pending.len());
|
||
for batch in case_jobs.chunks(HARVEST_BATCH_CASES) {
|
||
let results: std::collections::HashMap<(Uuid, String), Box<RawValue>> = sqlx::query!(
|
||
"SELECT branch.parent_job AS \"case_job!\", scorer.flow_step_id AS \"module!\",
|
||
done.result AS \"result: sqlx::types::Json<Box<RawValue>>\"
|
||
FROM v2_job branch
|
||
JOIN v2_job scorer ON scorer.parent_job = branch.id
|
||
JOIN v2_job_completed done ON done.id = scorer.id
|
||
WHERE branch.parent_job = ANY($1) AND branch.workspace_id = $2
|
||
AND scorer.flow_step_id = ANY($3)",
|
||
batch,
|
||
w_id,
|
||
&modules
|
||
)
|
||
.fetch_all(db)
|
||
.await?
|
||
.into_iter()
|
||
.map(|row| {
|
||
let result = row
|
||
.result
|
||
.map(|json| json.0)
|
||
.unwrap_or_else(|| RawValue::from_string("null".to_string()).expect("a literal"));
|
||
((row.case_job, row.module), result)
|
||
})
|
||
.collect();
|
||
let in_batch: std::collections::HashSet<Uuid> = batch.iter().copied().collect();
|
||
for row in pending.iter().filter(|row| in_batch.contains(&row.job_id)) {
|
||
// Nothing left to read the verdict out of. Settled here, since a cell left pending is
|
||
// one every later listing would go back to this same absent job for.
|
||
if !row.job_exists {
|
||
verdicts.push((
|
||
row.ordinal,
|
||
row.scorer_id.clone(),
|
||
Some((
|
||
Verdict::default(),
|
||
Some("The run that produced this score is no longer available".to_string()),
|
||
)),
|
||
));
|
||
continue;
|
||
}
|
||
// What to say when the job is over and this scorer left nothing. Only
|
||
// `record_case_answers` tells the two states apart and a listing syncs without it, so
|
||
// `None` withholds the sentence — not the harvest: a scorer that returned a number is
|
||
// read and recorded either way.
|
||
let missing = row.answered.map(|answered| {
|
||
if answered {
|
||
"This scorer did not run for the case"
|
||
} else {
|
||
"The case produced no answer to score"
|
||
}
|
||
});
|
||
let result = results
|
||
.get(&(row.job_id, scorer_module_id(&row.scorer_id)))
|
||
.map(|r| r.as_ref());
|
||
let verdict = settle_verdict(result, row.status.as_deref(), missing);
|
||
verdicts.push((row.ordinal, row.scorer_id.clone(), verdict));
|
||
}
|
||
}
|
||
|
||
// One statement for every cell read, for the same reason the answers are written that way.
|
||
let mut ordinals = vec![];
|
||
let mut scorer_ids = vec![];
|
||
let mut scores = vec![];
|
||
let mut reasons = vec![];
|
||
let mut checks = vec![];
|
||
let mut errors = vec![];
|
||
let mut not_applicable = vec![];
|
||
for (ordinal, scorer_id, read) in verdicts {
|
||
// Still to come: a scorer whose own step has not run yet.
|
||
let Some((verdict, error)) = read else {
|
||
continue;
|
||
};
|
||
ordinals.push(ordinal);
|
||
scorer_ids.push(scorer_id);
|
||
scores.push(verdict.score);
|
||
reasons.push(verdict.reason);
|
||
checks.push(verdict.checks);
|
||
errors.push(error);
|
||
not_applicable.push(verdict.not_applicable);
|
||
}
|
||
if ordinals.is_empty() {
|
||
return Ok(());
|
||
}
|
||
sqlx::query!(
|
||
"UPDATE eval_score s
|
||
SET score = t.score, reason = t.reason, checks = t.checks, error = t.error,
|
||
not_applicable = t.not_applicable
|
||
FROM UNNEST($2::int[], $3::text[], $4::double precision[], $5::text[], $6::jsonb[],
|
||
$7::text[], $8::bool[])
|
||
AS t(ordinal, scorer_id, score, reason, checks, error, not_applicable)
|
||
WHERE s.experiment_id = $1 AND s.ordinal = t.ordinal AND s.scorer_id = t.scorer_id",
|
||
experiment_id,
|
||
&ordinals,
|
||
&scorer_ids,
|
||
&scores as &[Option<f64>],
|
||
&reasons as &[Option<String>],
|
||
&checks as &[Option<serde_json::Value>],
|
||
&errors as &[Option<String>],
|
||
¬_applicable,
|
||
)
|
||
.execute(db)
|
||
.await?;
|
||
Ok(())
|
||
}
|
||
|
||
/// One scorer's verdict, from the result of the step that produced it, inside a job that may
|
||
/// still be running: a scorer's own step can be done while the iteration around it is not. `None`
|
||
/// while the result is not readable yet, which is a state to wait through rather than to record
|
||
/// as a failure; `Some` with an error is a scorer that produced nothing, worded by where it ran.
|
||
fn settle_verdict(
|
||
result: Option<&RawValue>,
|
||
job_status: Option<&str>,
|
||
// What to record when the job is over and this scorer produced nothing. A different statement
|
||
// depending on where the scorer ran: its own job failed, or the case it was to score never
|
||
// produced an answer. `None` when the caller cannot yet tell those apart, which leaves the
|
||
// cell pending for a read that can, rather than settling it on the wrong one of the two.
|
||
missing_error: Option<&str>,
|
||
) -> Option<(Verdict, Option<String>)> {
|
||
Some(match result {
|
||
Some(value) => {
|
||
let verdict = extract_verdict(value);
|
||
match verdict {
|
||
// A score is a fraction: the mean and the pass rate read it as one, so a number
|
||
// outside that range is recorded as an error rather than a value that would
|
||
// quietly skew the column.
|
||
Verdict { score: Some(score), .. } if !(0.0..=1.0).contains(&score) => (
|
||
Verdict::default(),
|
||
Some(format!(
|
||
"The scorer returned {}, outside the 0 to 1 range a score must be in",
|
||
score
|
||
)),
|
||
),
|
||
// A number in range, or the scorer saying this case is not one it measures. Both
|
||
// are answers, so neither is an error.
|
||
Verdict { score: Some(_), .. } | Verdict { not_applicable: true, .. } => {
|
||
(verdict, None)
|
||
}
|
||
// The job around this scorer is still going, so a module with no number in it is
|
||
// one that has not run yet. Recording a failure here would make it permanent.
|
||
_ if job_status.is_none() => return None,
|
||
_ if job_status == Some("success") => (
|
||
verdict,
|
||
Some("The scorer returned no number to plot".to_string()),
|
||
),
|
||
_ => match missing_error {
|
||
Some(missing) => (verdict, Some(missing.to_string())),
|
||
None => return None,
|
||
},
|
||
}
|
||
}
|
||
// The iteration is over, so a scorer step with no readable result produced nothing and
|
||
// never will; left pending it would be re-read on every listing.
|
||
None if job_status == Some("success") => (
|
||
Verdict::default(),
|
||
Some("The scorer step produced no result".to_string()),
|
||
),
|
||
// The job holding this scorer has not finished, so a module with nothing in it yet is a
|
||
// step that has not run rather than one that produced nothing.
|
||
None if job_status.is_none() => return None,
|
||
None => match missing_error {
|
||
Some(missing) => (Verdict::default(), Some(missing.to_string())),
|
||
None => return None,
|
||
},
|
||
})
|
||
}
|
||
|
||
/// The score and reason read straight out of text that failed to parse as JSON. Deliberately not a
|
||
/// second JSON parser: it looks for the two keys and takes what follows, which is what survives a
|
||
/// model writing an unescaped quote in the middle of a sentence.
|
||
fn salvage_verdict(text: &str) -> (Option<f64>, Option<String>) {
|
||
fn after_key<'a>(text: &'a str, key: &str) -> Option<&'a str> {
|
||
let start = text.find(key)? + key.len();
|
||
Some(text[start..].trim_start().strip_prefix(':')?.trim_start())
|
||
}
|
||
|
||
let score = after_key(text, "\"score\"").and_then(|rest| {
|
||
if rest.starts_with("true") {
|
||
return Some(1.0);
|
||
}
|
||
if rest.starts_with("false") {
|
||
return Some(0.0);
|
||
}
|
||
let end = rest
|
||
.find(|c: char| !matches!(c, '0'..='9' | '.' | '-' | '+' | 'e' | 'E'))
|
||
.unwrap_or(rest.len());
|
||
rest[..end].parse::<f64>().ok()
|
||
});
|
||
|
||
// To the last quote of the object, so an unescaped one inside the sentence stays part of it.
|
||
let reason = after_key(text, "\"reason\"")
|
||
.and_then(|rest| rest.strip_prefix('"'))
|
||
.and_then(|rest| {
|
||
let body = match rest.rfind('}') {
|
||
Some(brace) => &rest[..brace],
|
||
None => rest,
|
||
};
|
||
let end = body.rfind('"')?;
|
||
Some(body[..end].to_string())
|
||
})
|
||
.filter(|reason| !reason.is_empty());
|
||
|
||
(score, reason)
|
||
}
|
||
|
||
/// A fenced code block as the model wrote it, reduced to what is inside the fence. The opening
|
||
/// fence carries a language tag often enough that the first line goes with it.
|
||
fn unfence(text: &str) -> &str {
|
||
let trimmed = text.trim();
|
||
let Some(rest) = trimmed.strip_prefix("```") else {
|
||
return trimmed;
|
||
};
|
||
let inner = match rest.split_once('\n') {
|
||
Some((_language, body)) => body,
|
||
None => rest,
|
||
};
|
||
inner.trim_end().trim_end_matches("```").trim()
|
||
}
|
||
|
||
/// What a scorer said about one run. `not_applicable` is the scorer declining to measure this
|
||
/// case: an explicit `{"score": null}`. A bare `null` stays an error, since a scorer that forgot
|
||
/// to return is indistinguishable from one that returned nothing on purpose.
|
||
#[derive(Default)]
|
||
struct Verdict {
|
||
score: Option<f64>,
|
||
reason: Option<String>,
|
||
checks: Option<serde_json::Value>,
|
||
not_applicable: bool,
|
||
}
|
||
|
||
impl Verdict {
|
||
fn scored(score: f64) -> Self {
|
||
Verdict { score: Some(score), ..Default::default() }
|
||
}
|
||
}
|
||
|
||
/// A scorer may return a bare number, a boolean, or `{score, reason, checks}`; an agent wraps its
|
||
/// answer in `output`, sometimes as a string holding any of those. Anything with no number in it
|
||
/// is left empty rather than guessed at.
|
||
fn extract_verdict(value: &RawValue) -> Verdict {
|
||
let Ok(parsed) = serde_json::from_str::<serde_json::Value>(value.get()) else {
|
||
return Verdict::default();
|
||
};
|
||
fn as_number(value: &serde_json::Value) -> Option<f64> {
|
||
match value {
|
||
serde_json::Value::Number(n) => n.as_f64(),
|
||
serde_json::Value::Bool(b) => Some(if *b { 1.0 } else { 0.0 }),
|
||
_ => None,
|
||
}
|
||
}
|
||
if let Some(number) = as_number(&parsed) {
|
||
return Verdict::scored(number);
|
||
}
|
||
let serde_json::Value::Object(map) = &parsed else {
|
||
// A judge often answers with JSON inside a string, and often fences it as markdown even
|
||
// when told to reply with JSON only.
|
||
if let serde_json::Value::String(text) = &parsed {
|
||
let text = unfence(text);
|
||
if let Ok(inner) = serde_json::from_str::<serde_json::Value>(text) {
|
||
if let Ok(raw) = serde_json::value::to_raw_value(&inner) {
|
||
return extract_verdict(&raw);
|
||
}
|
||
}
|
||
// Nearly JSON: a judge that quotes the agent inside its own reason writes those quotes
|
||
// unescaped, which is invalid and also the most ordinary thing for it to say. The
|
||
// number is what the column plots, so it is read out of the text rather than lost with
|
||
// the object around it.
|
||
let (score, reason) = salvage_verdict(text);
|
||
return Verdict { score, reason, checks: None, not_applicable: false };
|
||
}
|
||
return Verdict::default();
|
||
};
|
||
let reason = || {
|
||
map.get("reason")
|
||
.or_else(|| map.get("comment"))
|
||
.and_then(|r| r.as_str())
|
||
.map(|r| r.to_string())
|
||
};
|
||
if let Some(score) = map.get("score").and_then(as_number) {
|
||
return Verdict {
|
||
score: Some(score),
|
||
reason: reason(),
|
||
checks: map.get("checks").cloned(),
|
||
not_applicable: false,
|
||
};
|
||
}
|
||
// Written out rather than merely absent, which is what separates it from a scorer that
|
||
// returned an object with no verdict in it at all.
|
||
if map.get("score").is_some_and(|s| s.is_null()) {
|
||
return Verdict {
|
||
score: None,
|
||
reason: reason(),
|
||
checks: map.get("checks").cloned(),
|
||
not_applicable: true,
|
||
};
|
||
}
|
||
match map.get("output") {
|
||
Some(output) => match serde_json::value::to_raw_value(output) {
|
||
Ok(raw) => extract_verdict(&raw),
|
||
Err(_) => Verdict::default(),
|
||
},
|
||
None => Verdict::default(),
|
||
}
|
||
}
|
||
|
||
#[cfg(test)]
|
||
mod tests {
|
||
use super::*;
|
||
|
||
fn raw(json: &str) -> Box<RawValue> {
|
||
serde_json::from_str(json).unwrap()
|
||
}
|
||
|
||
/// A scorer's answer arrives in whatever shape its runnable returns: a script's bare value or
|
||
/// object, or a judge's answer wrapped in `output` and often stringified. A shape that goes
|
||
/// unrecognised is a silently empty cell rather than an error.
|
||
#[test]
|
||
fn extract_verdict_reads_every_documented_scorer_shape() {
|
||
let score = |json: &str| extract_verdict(&raw(json)).score;
|
||
assert_eq!(score("0.75"), Some(0.75));
|
||
assert_eq!(score("true"), Some(1.0));
|
||
assert_eq!(score(r#"{"score": 0.5}"#), Some(0.5));
|
||
assert_eq!(score(r#"{"score": false}"#), Some(0.0));
|
||
|
||
// judges and agent scorers: the answer is under `output`, sometimes as a string
|
||
assert_eq!(score(r#"{"output": 0.25}"#), Some(0.25));
|
||
assert_eq!(score(r#"{"output": "0.9"}"#), Some(0.9));
|
||
assert_eq!(score(r#"{"output": {"score": 0.8}}"#), Some(0.8));
|
||
assert_eq!(score(r#"{"output": "{\"score\": 0.4}"}"#), Some(0.4));
|
||
|
||
// a judge told to reply with JSON only, replying with JSON only, in a code fence
|
||
assert_eq!(
|
||
score("{\"output\": \"```json\\n{\\\"score\\\": 0.15}\\n```\"}"),
|
||
Some(0.15)
|
||
);
|
||
assert_eq!(score("{\"output\": \"```\\n0.6\\n```\"}"), Some(0.6));
|
||
|
||
// A judge quoting the agent inside its own reason, which is invalid JSON.
|
||
let quoted = extract_verdict(&raw(
|
||
r#"{"output": "{\"score\": 0.8, \"reason\": \"invented context (\"stop asking me\", never said) here\"}"}"#,
|
||
));
|
||
assert_eq!(quoted.score, Some(0.8));
|
||
assert_eq!(
|
||
quoted.reason.as_deref(),
|
||
Some(r#"invented context ("stop asking me", never said) here"#)
|
||
);
|
||
|
||
// nothing numeric to plot: left empty rather than guessed at
|
||
assert_eq!(score(r#"{"output": "not a score"}"#), None);
|
||
assert_eq!(score(r#"{"verdict": "good"}"#), None);
|
||
|
||
let full = extract_verdict(&raw(
|
||
r#"{"score": 0.5, "reason": "half", "checks": [{"name": "a"}]}"#,
|
||
));
|
||
assert_eq!(
|
||
(full.score, full.reason),
|
||
(Some(0.5), Some("half".to_string()))
|
||
);
|
||
assert!(full.checks.is_some());
|
||
assert!(!full.not_applicable);
|
||
|
||
// `comment` as the rationale, which is what a scorer written for LangSmith or Langfuse
|
||
// returns. Read rather than dropped, since the number arrives either way.
|
||
assert_eq!(
|
||
extract_verdict(&raw(r#"{"score": 1, "comment": "fine"}"#))
|
||
.reason
|
||
.as_deref(),
|
||
Some("fine")
|
||
);
|
||
}
|
||
|
||
/// A score is a fraction: anything outside 0..=1 (a scorer that returned a count, say) is
|
||
/// recorded as an error naming the value rather than plotted as a bogus point.
|
||
#[test]
|
||
fn an_out_of_range_score_is_recorded_as_an_error_not_a_value() {
|
||
// In range: recorded as the score it is.
|
||
let (v, e) = settle_verdict(Some(&raw("0.5")), Some("success"), None).unwrap();
|
||
assert_eq!(v.score, Some(0.5));
|
||
assert!(e.is_none());
|
||
// Out of range (a scorer returning a count, say): no score, an error naming the value.
|
||
let (v, e) = settle_verdict(Some(&raw("100")), Some("success"), None).unwrap();
|
||
assert_eq!(v.score, None);
|
||
assert!(e.unwrap().contains("100"));
|
||
let (v, _) = settle_verdict(Some(&raw("-5")), Some("success"), None).unwrap();
|
||
assert_eq!(v.score, None);
|
||
// No result at all once the iteration is over: an error, not a cell pending forever.
|
||
let (v, e) = settle_verdict(None, Some("success"), None).unwrap();
|
||
assert_eq!(v.score, None);
|
||
assert!(e.is_some());
|
||
// Still running: nothing to settle yet.
|
||
assert!(settle_verdict(None, None, None).is_none());
|
||
}
|
||
|
||
/// A scorer saying it has nothing to measure on a case is a verdict rather than a failure: the
|
||
/// cell is left out of the mean instead of counted as a zero. Spelled out, so a scorer that
|
||
/// returns nothing at all is still an error rather than silently excused.
|
||
#[test]
|
||
fn an_explicit_null_score_is_not_applicable_rather_than_missing() {
|
||
let na = extract_verdict(&raw(r#"{"score": null, "reason": "no sources to cite"}"#));
|
||
assert!(na.not_applicable);
|
||
assert_eq!(na.score, None);
|
||
assert_eq!(na.reason.as_deref(), Some("no sources to cite"));
|
||
|
||
// Through a judge's wrapper, as any other verdict is.
|
||
assert!(extract_verdict(&raw(r#"{"output": {"score": null}}"#)).not_applicable);
|
||
assert!(extract_verdict(&raw(r#"{"output": "{\"score\": null}"}"#)).not_applicable);
|
||
|
||
// Not the same as a scorer that returned nothing, or an object with no verdict in it.
|
||
assert!(!extract_verdict(&raw("null")).not_applicable);
|
||
assert!(!extract_verdict(&raw(r#"{"verdict": "good"}"#)).not_applicable);
|
||
}
|
||
}
|