Files
windmill/frontend/src
Ruben Fiszel ecb1a92070 fix(copilot): stop write_flow forcing rawscript code into nested JSON (#10260)
* fix(copilot): stop write_flow forcing rawscript code into nested JSON

The global-chat write_flow tool made the model embed rawscript bodies
inside the modules JSON string, so code had to survive three levels of
escaping (tool arguments -> modules string -> content string). Models
routinely mangled the quotes/newlines and flow creation failed on the
first tries.

Bring write_flow to parity with flow mode's set_module_code escape hatch:
detect rawscript modules left empty or as inline_script placeholders and
tell the model to fill them via set_flow_module_code, add a code-escaping
hint to the JSON parse error, and update the guidance to keep code out of
the modules structure.

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

* fix(copilot): only warn on saved write_flow; add regression tests

Address review: writeFlowDraft reports conflicts/persistence errors as
{success:false} rather than throwing, so the empty-body warning must be
folded into the JSON result only on a successful save — otherwise the
model is told to set_flow_module_code on a flow that was never saved
(stale or nonexistent draft). Add core.test.ts coverage for the empty-body
warning (top-level, nested, preprocessor, failure; populated suppressed),
the no-warning-on-failed-save path, and the malformed-JSON escaping hint.

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

* fix(copilot): warn on patch_flow_json inline_script placeholders

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test(ai-evals): add global case for quote-heavy inline flow code

Exercises write_flow creating a rawscript whose body is multi-line and
quote-heavy (the scenario the write_flow fix targets), so the global-mode
A/B can measure that code lands out-of-band via set_flow_module_code
rather than being escaped into the modules JSON string.

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

* fix(copilot): resolve inline_script placeholders in global flow writes

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor(copilot): condense patch_flow_json warning comment

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(copilot): soften write_flow guidance to inline by default

Benchmarks showed the aggressive "empty content + set_flow_module_code
for any multi-line/quoted body" guidance pushed even capable models onto
the multi-round-trip fill path, inflating per-iteration overhead with no
reliability gain when inline escaping would have succeeded. Default to
inlining and reserve the empty+fill escape hatch for bodies that are
genuinely hard to escape or when a write_flow call returns a JSON parse
error — the case that actually benefits escaping-prone models. The
warning, parse-error hint, and set_flow_module_code recovery path are
unchanged.

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

* test(ai-evals): drop global quote-heavy inline-code case

The manual global-mode A/B (Sonnet, Gemini 3 flash/pro, GPT-4o) showed no
pass-rate delta: the GPT-5 inline-escaping failure this change targets does
not reproduce on any available model, so the case guards nothing measurable.
Keep the unit tests as the regression guard instead.

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

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Guilhem Lemouel <guilhemlemouel@gmail.com>
2026-07-22 16:21:13 +02:00
..
2025-11-29 01:23:47 +00:00