feat(claude): report workflow runs as structured phases and agents - #26
Merged
Merged
Conversation
A Claude Workflow run is a `workflow` task. Its AgentTask::workflow now carries the run's phases, agents (label, phase, normalized state, model, tokens, tool calls, timings, latest tool, prompt and result previews) and recent logs, parsed from Claude's workflow_progress and replaced on every update, plus the run's name, identifier and transcript directory from the Workflow tool's result. Collections and text are bounded because every tick carries the whole workflow. Workflow TaskActivity now records agent state changes, with the changed agent in AgentTaskActivity::workflow_agent, instead of one Progress per tick. Claude does not stream a workflow agent's own tool calls, so AgentWorkflow::agent_transcript_path (plain agent identifiers only) and Claude::transcript_activity rebuild an agent's text and tool calls from its transcript with the live parser. Also attributes a background shell's Bash result to its shell task. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every workflow tick carries the whole snapshot, and consumers commonly persist each event. A tick that only moves counters (tokens, tool calls, durations, latest tool) is now re-emitted once per five such ticks, while any state, result, error, phase or log change is emitted at once. The held snapshot is still updated on every tick, so the next emission is current. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
… change nothing Transcripts record reasoning only as thinking blocks, so transcript_activity now returns them as ReasoningDelta. Workflow ticks without workflow_progress or with an identical snapshot no longer resend the whole workflow; counter changes still go out at most every fifth tick. Docs no longer imply that transcript entries are redacted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
@greptile-apps review |
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.
Summary
A run of Claude Code's
Workflowtool reaches consumers as oneworkflowtask plus aTaskActivityof kindProgresson every tick. Each of those activities has the same description and the most recently active agent's label inlast_tool_name. A UI built on that shows hundreds of near-identical rows and no structure.Claude already reports the structure. Each workflow
task_progresscarries aworkflow_progresslist: phases, agents with their state, tokens, tool calls, timings and previews, and script logs. TheWorkflowtool's result also names the run's transcript directory. This PR surfaces that.Workflow snapshot
AgentTask::workflow: Option<AgentWorkflow>, replaced on every update:name,run_idandtranscript_dir, taken fromtask_started.workflow_nameand theWorkflowtool'stool_use_result.phases: index, title and kind.agents: index, label, phase, normalizedstate, the rawnative_state,agent_id, model, type, isolation, attempt,cached, tokens, tool calls, duration, queued/started/last-progress times,last_tool_name/last_tool_summary, prompt and result previews, anderror. Normalized states are queued, running, completed, failed and blocked.logs(the last 10) andomitted_agents.Every tick resends the whole workflow, so it is bounded: 100 agents, 32 phases, and 240 characters per text field.
Activity per agent state change, not per tick
For a workflow task,
TaskActivityis emitted only when an agent appears or changes state. The changed agent is in the newAgentTaskActivity::workflow_agent(boxed), andsummaryreads likescan:read completed. A real 3-agent run now produces 7 activities, one per agent state change.Per-agent activity
Claude does not stream a workflow agent's own tool calls; it writes them to
<transcriptDir>/agent-<agentId>.jsonl.AgentWorkflow::agent_transcript_path(agent)returns that path. It does so only for plain agent IDs ([A-Za-z0-9_-]), so a value reported by the provider cannot point outside the directory.Claude::transcript_activity(transcript, max_entries)replays the transcript through the adapter's live parser. It returns timestampedTextDelta/ReasoningDelta/ToolCallevents with the same bounds and redaction as a live turn, skips a line that is still being written, and keeps the most recent entries.Also
Bashcall now carries the shell task's ID, so it groups under that task. Fleet had been carrying this as a local patch on its vendored copy; this upstreams it with its test.Compatibility
AgentTaskandAgentTaskActivitygain fields, so code that builds them literally must setworkflow/workflow_agent(this is noted in the CHANGELOG). Both fields are#[serde(default)], so previously stored tasks and activities still deserialize; a test covers this.Testing
Workflowrun (paths replaced, attachments dropped). They cover:max_entries;local_bashattribution.cargo run --example claude_workflow_smokeprintedPASS.Scan/Reportand 3 completed agents, with tokens, tool counts and latest tool.Read/Bashcalls.-D warnings(Rust 1.99), the feature matrix, package checks,cargo doc,cargo package, fullstack-example clippy, andcargo test --all-features(415 tests).🤖 Generated with Claude Code