Repository navigation
Builder: edits on edit_workflow / edit_step; document reads bound by the window, not the 50k ceiling - #131
Merged
Conversation
…y the window, not the 50k ceiling The builder could not change one line of a 50k-char workflow a person made in the UI (tweet-engagement-study, 2026-10-09). Its own edit_workflow never had an ownership gate, but it took only the whole YAML, and get_workflow is cut at the tool result cap (50k chars on a 1M window; the "about 50k characters" the builder reported was the truncation marker). So it published a throwaway workflow (exec cat -> meta/publish-workflow) and hit the evolve surface's rule instead: a meta/* step republishes only over names it stamped `ai`, and relayed that as "refused for workflows I didn't originally create". - edit_workflow / edit_step take `edits`: exact-string replacements applied in order to the ACTIVE version's source, each required to match exactly once (`applyEdits`, authoring.ts). A no-match or a repeated match names the edit and the lines it hit and publishes nothing; validation and the claims gate run on the result as before. Pass `yaml` / `code` OR `edits`, not both. - get_workflow and get_step (`DOCUMENT_TOOLS`, chat-store.ts) are capped by the window's headroom alone (`AiDeps.documentMaxChars`, no env ceiling: 176k chars on a 1M window) and never re-cut on replay (`truncateToolMessages` skips them): the number they were cut to follows the model, and a fixed cap there would rewrite what the model already read (the append-only rule). - The system prompt says to use edits for a small change to a big workflow and never to work around a long YAML by other means. The meta/publish-workflow ownership rule is unchanged (EVOLVE_SPEC §6). The tool-result-spill plan's "error instead of a cut" exemption is noted as superseded: with edits a cut document is still editable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The builder could not change one line (
max_pages: 3→100) of a ~50k-char workflow made in the UI. Its ownedit_workflownever had an ownership gate, but it only took the whole YAML back, andget_workflowis cut at the tool result cap (50k chars on a 1M window — the "about 50k characters" it reported is the truncation marker). So the builder published a throwaway workflow (exec cat→meta/publish-workflow) and hit the evolve surface's rule instead: ameta/*step republishes only over names it stampedai(EVOLVE_SPEC §6). The chat transcript confirms the chain:tmp-republish-from-filepublished, run1791566214864returnedWorkflow "tweet-engagement-study" exists and is not agent-authored (publisher: none), relayed as "refused for workflows I didn't originally create".What
edit_workflow/edit_steptakeedits— exact-string replacements applied in order to the ACTIVE version's source, each required to match exactly once (applyEdits,src/authoring.ts). A no-match or a repeated match names the edit and the lines it hit, and publishes nothing; validation and the claims gate run on the result as before.yaml/codeORedits, not both. The fix for the tweet workflow is now one call:edit_workflow({ name, edits: [{ old: "max_pages: 3", new: "max_pages: 100" }] }).get_workflowandget_step(DOCUMENT_TOOLS,src/chat-store.ts) getAiDeps.documentMaxChars— the window's headroom with no env ceiling, 176k chars on a 1M window (every Claude 5 model), 16k on Haiku 4.5 — and are never re-cut on replay:truncateToolMessagesskips them, since the number they were cut to follows the model and a fixed cap there would rewrite what the model already read (the append-only rule; a cache miss and, on preserved-thinking models, a 400). Every other result keeps the 50k ceiling.editsfor a small change to a big workflow and never to work around a long YAML by other means.get_workflow,get_stepUnchanged
meta/publish-workflowownership rule — it guards an unsupervised agent inside a run.edits, a cut document is still editable).Tests
npm test: 1386 pass. New:editson both tools (one-line change, no-match, repeated match with line numbers, validation error after an edit, edits follow the active version after a rollback), the document cap at the source vs the ordinary cap, and the replay skip. Not exercised against a live model: the change is tool schema + execute logic, not provider streaming.tscclean.