Handle the full variety of Workflow invocation shapes (#174 follow-up)#258
Conversation
…ve script Real Workflow invocations come in more shapes than the inline-`script` one (#174 assumed): `scriptPath` / `name` / `resumeFromRunId` inputs carry no source at all, so the JS-meta parse came up empty and the snapshot-first header fired spurious "meta format may have drifted" warnings on every such run (observed on all 5 runs of the SAM reference session). The terminal <runId>.json snapshot stores the script that actually ran, plus scriptPath, args, summary, error, defaultModel, durationMs and totalToolCalls — surface them all on WorkflowRun. The header now parses the *effective* script (input, else snapshot copy; new resolve_workflow_script helper), falls back to the snapshot `summary` for a missing description, and warns only when a NON-empty script fails a parse the snapshot can answer — absent source is not drift. Also fix the meta string regexes: real meta blocks contain backslash-escaped quotes ('SAM\'s ...'), which truncated the parsed description; strings now match any JS quote style (' / " / backtick) with escape support and are unescaped on extraction. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
scriptPath, name, args and resumeFromRunId are all legal Workflow inputs (the SAM reference session uses scriptPath exclusively), but the model declared only `script` — the other shapes fell into extra="allow" and were invisible to the formatters. Declare them with their camelCase aliases so the renderer can surface them. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
For the scriptPath / name / resumeFromRunId invocation shapes the tool_use card showed a bare header pill row: no source, no description, no hint of how the workflow was launched. Now, in HTML and Markdown: - the script body falls back to the snapshot-stored copy of the source that actually ran (resolve_workflow_script), so scriptPath runs show their orchestrator just like inline ones; - a workflow-invocation line surfaces the saved-workflow name, the script file reference, and the resumed run id; - `args` renders through the hybrid params table (HTML) / a fenced JSON block (Markdown), wrapped under an explicit "args" key. New workflow_scriptpath fixture: a scriptPath+args invocation whose snapshot carries the script (with an escaped quote in the meta description, exercising the commit-1 string parse). Snapshot .ambr churn is the new CSS block only. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A workflow that dies before launching any agent (e.g. a script error on an early line — observed as wf_700cd51d in the SAM reference session) leaves a <runId>.json snapshot but NO run dir/journal. Journal-led discovery skipped it entirely: no run link, no header, and the error nowhere on the page. - discover_workflow_runs also yields snapshot-only runs (snapshots with no matching run dir); parse_workflow_run accepts a missing journal when the snapshot loads, producing a run with an empty agents list. - The tool_use header now shows a status chip for any non-completed terminal status next to the workflow name, and the snapshot `error` (typically a JS stack trace) as a collapsed fold — in HTML and Markdown. WorkflowRun.status was previously parsed but never rendered; error wasn't even parsed. Fixture: wf_fail01 snapshot-only failed run added to the workflow_scriptpath session. Snapshot .ambr churn is the new CSS only. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Same convention as gen_workflow_fixture.py: the fixture is checked in but regenerable. Regenerated output (cosmetic JSON key-order change in the trunk only). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Document the invocation shapes (script / scriptPath / name / args / resumeFromRunId), the snapshot enrichment fields and script recovery route, snapshot-only failed-run discovery, the effective-script header resolution with its narrowed drift warning, the failure chrome, and the workflow_scriptpath fixture. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (15)
📝 WalkthroughWalkthroughThis PR extends the dynamic Workflow tool to support multiple invocation shapes (inline ChangesWorkflow invocation shapes and snapshot-driven rendering
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
If I may add a little note of self-satisfaction, our dynamic workflow rendering really nails it. @daaain, maybe it's time to cut a new release? |
Summary
The #174 dynamic-workflow rendering assumed the inline-
scriptinvocation shape. Real sessions use others — a reference session's 6Workflowtool_uses were allscriptPathinvocations (one withargs), which produced bare headers (no source, no description, invisible args) and a spuriousmeta format may have driftedwarning per run per field. One run there also failed before launching any agent, leaving a snapshot but no journal — journal-led discovery skipped it entirely, so itsfailedstatus and error appeared nowhere.workflow.py): surface the terminal snapshot's full enrichment onWorkflowRun—script(the source that actually ran: the recovery route for non-inline shapes),scriptPath,args,summary,error,defaultModel,durationMs,totalToolCalls. The header resolves from the effective script (input, else snapshot copy), falls back to the snapshotsummaryfor a missing description, and warns only when a non-empty script fails a parse the snapshot can answer — absent source is not drift.'/"/backtick) with backslash-escape support — real meta descriptions contain\', which truncated the old parse mid-string.models.py):WorkflowToolInputdeclares the invocation union —script,scriptPath,name,args,resumeFromRunId— instead of dropping the non-inline fields intoextra="allow".workflow-invocationline shows saved-workflow name / scriptPath reference / resumed run id;argsrenders via the hybrid params table (HTML) / fenced JSON (Markdown).completedstatus renders as a chip next to the workflow name and the snapshoterroras a collapsed fold — in both output formats.Verification
test/test_data/workflow_scriptpath/(checked-in generator, same convention asworkflow_basic): ascriptPath+argsrun whose snapshot carries the script (meta description with an escaped quote) + a snapshot-onlyfailedrun.test/test_workflow_rendering.py;just cigreen on every commit; snapshot.ambrchurn is the new CSS only.dev-docs/workflows.mdupdated in-PR.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation