Repository navigation
feat(chatd): add the workflow run engine behind fork-workflows - #238
Conversation
run_workflow starts a Starlark program that runs sub-agent steps and combines their workflow_report values; await_workflow waits for the result. The registry keeps the runs of one replica in memory, so a restart loses a run and the model resumes it with resume_run_id: the deterministic step IDs reuse the finished step chats (PR 1a plumbing). script_path reads the script from the workspace through the live turn's agent connection, and run_workflow serializes after the other tool calls of its batch, so a write in the same batch lands first. Part of #226
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e60e3e8cca
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
forkWorkflowTools returns run_workflow and await_workflow regardless of the connection option; the nil-connection subtest asserted one tool.
…d keep the one-reminder limit Codex round 1 P1 fixes on PR #238: - The result and step schema budgets now walk the Starlark value before json.encode materializes its string, so a script that builds a huge value by doubling a string fails with the size error instead of allocating the encoded copy first. - A script that ends without waiting for a spawned step no longer leaves the child chat working to its step deadline: execute interrupts the child chats of unreported steps and marks the steps failed. - The one-reminder limit no longer relies on matching the reminder text in the child history, which a user_prompt_submit hook rewrite breaks: the run records its own send on the step.
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2b9d02ba5b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…t steps Codex round 2 fixes on PR #238: - The budget walk now counts each string byte that escapes as six output bytes and any other byte as one, matching how the json module quotes printable ASCII with strconv.AppendQuote and hands the rest to json.Marshal. The advertised 64 KiB result and schema limits are real again for ordinary values, and the estimate still never under-counts. - The size errors carry their context (result or schema) so the tests can assert them. - A step that passes its deadline now interrupts its child chat before waitStep returns: the terminal cleanup no longer sees a failed step.
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 567f7851cf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- log() and print retained their full value: maxWorkflowLogs bounded only the line count, so a script could keep 50 unbounded strings alive and duplicate them into every run snapshot. Each retained line is now cut to 4 KiB on a rune boundary and the retained lines total at most maxResultBytes, dropping the oldest first. - the pre-encode walk charged every small integer 12 bytes, so a valid numeric result under 64 KiB (6000 zeroes, for example) was rejected; small integers now cost their exact decimal width and big integers keep the conservative digit estimate. - SchemaSizeBeforeEncode used a 20 KB description that passes the exact 64 KiB budget, so the run completed instead of failing; the payload now exceeds the budget on its own. - ReminderFlagOutlivesScanBlindness blocked inside waitStep: after the reminder the step waits for the child's turn to end, and on the passive fixture only the test can end it. The subtest now ends the turn once the reminder is on record.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 60ce015745
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Merge gates on head 60ce015:
fork-workflows stays gated. The owner-gate PR must land before fork-workflows is enabled anywhere. |
Part of #226. Second PR of the chat-workflows stack: the Starlark run engine that the PR 1a plumbing serves. Behind
fork-workflows; with the flag off, chatd behaves exactly like upstream.What this adds
fork_workflow.go: therun_workflowandawait_workflowchat tools and the run lifecycle.run_workflowcompiles the script, returnsrunningat once, and the program continues in a chatd inflight goroutine. Itsagent()/spawn()/wait()/log()built-ins create step children through the PR 1a plumbing, block on them, and combine theirworkflow_reportvalues.await_workflowblocks until the run ends or its wait elapses; with no awaiter the run queues an end notice on the parent, which the first awaiter deletes. Limits: 64 KiB script, 50 steps per run, 10,000,000 Starlark execution steps, 64 KiB result, one reminder per unreported step.fork_workflow_starlark.go: the Starlark host, verbatim from the prototype.whileloops on, noload(), no clock, no files, no network; errors keep the Starlark backtrace with the line number.run_workflowagain withresume_run_id; the deterministic step IDs reuse the finished step chats instead of re-running them.script_path: the script can come from a workspace file, read once at run start through the live turn's agent connection.appendForkToolsgains a variadic option carrying that connection from the singleturn_environment.gohook line, so every existing caller stays valid andrun_workflowserializes after the other tool calls of its batch (a write in the same batch lands first).turn_environment.go; the Server gains the per-replicaworkflowsregistry next toforkPacks.Differences from the upstream prototype this ports (coder#31189)
appendForkToolsasforkWorkflowTools(p.experiments, root chat, no plan mode, no explore mode); the workspace connection travels as a variadic option instead of the prototype'srootChatToolsOptionsfield.startStepdelegates chat creation to PR 1a'screateWorkflowStepChat(which validates the exact report tool contract before persisting a child) instead of the prototype's inline creation, and applies the spec defaults before the step key so a resumed run derives the same IDs.sendSubagentMessage(resume validation and family limits apply, as for the other runtime-to-child sends).Known gaps
spawn/agentprompts or titles can grow step children without a byte cap. Every normal-path input is bounded (script, schema, result, log lines), but the step prompt and title are not. Rejected for this stack as abnormal input; a cap belongs in the same pass as the durable run journal.