test(orchestration-v2): replay a Claude workflow end to end
The adapter's workflow projection was covered in isolation and the panel derivation was covered against synthetic agents, but nothing drove real workflow frames through the orchestrator to the projection the client receives. Adds a claude_workflow replay fixture: a local_workflow task with two phases and two members, asserted on the resulting projection. Pins what the panel groups by — that members claim declared phases, that their membership points at the coordinator that actually reached the projection, and that the coordinator's usage still covers its members so subtracting theirs cannot go negative. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
ae3a724dc9
commit
39bc22bb2e
4 files changed
+135
No files matched your search
+12
@@ -0,0 +1,12 @@
|
||||
{"type": "transcript_start", "provider": "claudeAgent", "protocol": "claude-agent-sdk.query", "version": "0.2.111", "scenario": "claude_workflow", "metadata": {"prompts": ["Run a two-phase workflow, then answer exactly: claude workflow fixture complete"], "model": "claude-sonnet-4-6", "nativeSessionId": "3c7f21a0-9d4e-4b21-8f60-000000000201", "queryMode": "streaming", "tools": "claude_code", "permissionMode": "bypassPermissions", "generatedBy": "hand-authored-workflow-observability"}}
|
||||
{"type": "expect_outbound", "label": "query.open", "frame": {"type": "query.open", "options": {"model": "claude-sonnet-4-6", "tools": {"type": "preset", "preset": "claude_code"}, "permissionMode": "bypassPermissions", "allowDangerouslySkipPermissions": true, "sessionId": "3c7f21a0-9d4e-4b21-8f60-000000000201"}}}
|
||||
{"type": "expect_outbound", "label": "prompt.offer:1", "frame": {"type": "prompt.offer", "message": {"type": "user", "message": {"role": "user", "content": "Run a two-phase workflow, then answer exactly: claude workflow fixture complete"}, "parent_tool_use_id": null}}}
|
||||
{"type": "emit_inbound", "label": "system", "frame": {"type": "system", "subtype": "init", "agents": [], "apiKeySource": "none", "claude_code_version": "2.1.183", "cwd": "/tmp/claude-replay-claude_workflow", "tools": [], "mcp_servers": [], "model": "claude-sonnet-4-6", "permissionMode": "bypassPermissions", "slash_commands": [], "output_style": "default", "skills": [], "plugins": [], "fast_mode_state": "off", "uuid": "af3bf4cc-1385-4e19-a5fa-fcbe2a0ca201", "session_id": "3c7f21a0-9d4e-4b21-8f60-000000000201"}}
|
||||
{"type": "emit_inbound", "label": "assistant:commentary", "frame": {"type": "assistant", "message": {"model": "claude-sonnet-4-6", "id": "msg_01claudeworkflow1", "type": "message", "role": "assistant", "content": [{"type": "text", "text": "Starting the two-phase workflow."}], "stop_reason": null, "stop_sequence": null, "stop_details": null, "usage": {"input_tokens": 1, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0, "output_tokens": 1, "service_tier": "standard", "inference_geo": "not_available"}, "context_management": null}, "parent_tool_use_id": null, "session_id": "3c7f21a0-9d4e-4b21-8f60-000000000201", "uuid": "97898e28-ee4e-4fcf-80c3-5c790c502201"}}
|
||||
{"type": "emit_inbound", "label": "task_started:local_workflow", "frame": {"type": "system", "subtype": "task_started", "task_id": "wf7ka2mq1", "tool_use_id": "toolu_01ClaudeWorkflowFixture01", "description": "Research and implement", "task_type": "local_workflow", "prompt": "Research the parser, then implement the fix.", "uuid": "4873c95b-1aa9-44a5-9783-dc56dac73201", "session_id": "3c7f21a0-9d4e-4b21-8f60-000000000201"}}
|
||||
{"type": "emit_inbound", "label": "task_progress:phase-1", "frame": {"type": "system", "subtype": "task_progress", "task_id": "wf7ka2mq1", "tool_use_id": "toolu_01ClaudeWorkflowFixture01", "description": "Research phase running", "usage": {"input_tokens": 300, "output_tokens": 200, "total_tokens": 500, "tool_uses": 4}, "workflow_progress": [{"type": "workflow_phase", "index": 0, "title": "Research"}, {"type": "workflow_phase", "index": 1, "title": "Implement"}, {"type": "workflow_agent", "index": 0, "label": "Researcher", "state": "active", "phaseIndex": 0, "attempt": 0, "model": "claude-sonnet-4-6", "lastToolName": "Read", "tokens": 200, "toolCalls": 2}], "uuid": "4873c95b-1aa9-44a5-9783-dc56dac73202", "session_id": "3c7f21a0-9d4e-4b21-8f60-000000000201"}}
|
||||
{"type": "emit_inbound", "label": "task_progress:phase-2", "frame": {"type": "system", "subtype": "task_progress", "task_id": "wf7ka2mq1", "tool_use_id": "toolu_01ClaudeWorkflowFixture01", "description": "Implement phase running", "usage": {"input_tokens": 700, "output_tokens": 500, "total_tokens": 1200, "tool_uses": 9}, "workflow_progress": [{"type": "workflow_phase", "index": 0, "title": "Research"}, {"type": "workflow_phase", "index": 1, "title": "Implement"}, {"type": "workflow_agent", "index": 0, "label": "Researcher", "state": "done", "phaseIndex": 0, "attempt": 0, "model": "claude-sonnet-4-6", "lastToolName": "Read", "tokens": 400, "toolCalls": 3}, {"type": "workflow_agent", "index": 1, "label": "Implementer", "state": "active", "phase_index": 1, "attempt": 0, "model": "claude-opus-4-1", "last_tool_name": "Edit", "tokens": 500, "tool_calls": 4}], "uuid": "4873c95b-1aa9-44a5-9783-dc56dac73203", "session_id": "3c7f21a0-9d4e-4b21-8f60-000000000201"}}
|
||||
{"type": "emit_inbound", "label": "task_notification:local_workflow", "frame": {"type": "system", "subtype": "task_notification", "task_id": "wf7ka2mq1", "tool_use_id": "toolu_01ClaudeWorkflowFixture01", "status": "completed", "output_file": "", "summary": "Workflow finished both phases.", "usage": {"input_tokens": 900, "output_tokens": 600, "total_tokens": 1500, "tool_uses": 11}, "uuid": "4873c95b-1aa9-44a5-9783-dc56dac73204", "session_id": "3c7f21a0-9d4e-4b21-8f60-000000000201"}}
|
||||
{"type": "emit_inbound", "label": "assistant:commentary", "frame": {"type": "assistant", "message": {"model": "claude-sonnet-4-6", "id": "msg_01claudeworkflow2", "type": "message", "role": "assistant", "content": [{"type": "text", "text": "claude workflow fixture complete"}], "stop_reason": null, "stop_sequence": null, "stop_details": null, "usage": {"input_tokens": 1, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0, "output_tokens": 1, "service_tier": "standard", "inference_geo": "not_available"}, "context_management": null}, "parent_tool_use_id": null, "session_id": "3c7f21a0-9d4e-4b21-8f60-000000000201", "uuid": "89be9e65-097b-47e8-849b-be723386b201"}}
|
||||
{"type": "emit_inbound", "label": "result", "frame": {"type": "result", "subtype": "success", "is_error": false, "api_error_status": null, "duration_ms": 4000, "duration_api_ms": 3500, "num_turns": 2, "result": "claude workflow fixture complete", "stop_reason": "end_turn", "session_id": "3c7f21a0-9d4e-4b21-8f60-000000000201", "total_cost_usd": 0.001, "usage": {"input_tokens": 2, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0, "output_tokens": 2, "server_tool_use": {"web_search_requests": 0, "web_fetch_requests": 0}, "service_tier": "standard", "cache_creation": {"ephemeral_1h_input_tokens": 0, "ephemeral_5m_input_tokens": 0}, "inference_geo": "", "iterations": [{"input_tokens": 1, "output_tokens": 1, "cache_read_input_tokens": 0, "cache_creation_input_tokens": 0, "cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0}, "type": "message"}], "speed": "standard"}, "modelUsage": {"claude-sonnet-4-6": {"inputTokens": 2, "outputTokens": 2, "cacheReadInputTokens": 0, "cacheCreationInputTokens": 0, "webSearchRequests": 0, "costUSD": 0.001, "contextWindow": 200000, "maxOutputTokens": 32000}}, "permission_denials": [], "terminal_reason": "completed", "fast_mode_state": "off", "uuid": "89be9e65-097b-47e8-849b-be723386b202"}}
|
||||
{"type": "runtime_exit", "status": "success"}
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { OrchestratorFixtureInput } from "../shared.ts";
|
||||
|
||||
export const CLAUDE_WORKFLOW_PROMPT =
|
||||
"Run a two-phase workflow, then answer exactly: claude workflow fixture complete";
|
||||
|
||||
/**
|
||||
* End-to-end cover for the Claude workflow coordinator. The adapter-level
|
||||
* projection of phases and workers is unit-tested, and the panel derivation is
|
||||
* unit-tested against synthetic agents — nothing joined the two. This drives
|
||||
* real workflow frames through the orchestrator so the coordinator, its
|
||||
* phases, and its members are asserted on the projection the client actually
|
||||
* receives, then feeds that projection to the panel derivation.
|
||||
*/
|
||||
export function claudeWorkflowInput(): OrchestratorFixtureInput {
|
||||
return {
|
||||
steps: [{ type: "message", text: CLAUDE_WORKFLOW_PROMPT }],
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import { assert } from "@effect/vitest";
|
||||
import type { ProviderReplayTranscript } from "@t3tools/contracts";
|
||||
|
||||
import type { OrchestratorV2ScenarioResult } from "../../OrchestratorScenario.ts";
|
||||
import {
|
||||
assertBaseProjection,
|
||||
assertSemanticProjectionIntegrity,
|
||||
assertUserMessagesInclude,
|
||||
projectionFor,
|
||||
} from "../shared.ts";
|
||||
import { CLAUDE_WORKFLOW_PROMPT } from "./input.ts";
|
||||
|
||||
export function assertClaudeWorkflowOutput(
|
||||
result: OrchestratorV2ScenarioResult,
|
||||
transcript: ProviderReplayTranscript,
|
||||
) {
|
||||
assertBaseProjection({ result, transcript, runCount: 1, runStatuses: ["completed"] });
|
||||
|
||||
const projection = projectionFor(result, transcript.scenario);
|
||||
assertSemanticProjectionIntegrity(projection);
|
||||
assertUserMessagesInclude(projection, [CLAUDE_WORKFLOW_PROMPT]);
|
||||
|
||||
const coordinator = projection.subagents.find((subagent) => subagent.kind === "workflow");
|
||||
assert.isDefined(coordinator, "the workflow must reach the projection as a coordinator");
|
||||
assert.deepEqual(coordinator?.role, { name: "workflow-coordinator", source: "app_default" });
|
||||
assert.deepEqual(coordinator?.workflow?.phases, [
|
||||
{ index: 0, title: "Research" },
|
||||
{ index: 1, title: "Implement" },
|
||||
]);
|
||||
|
||||
const members = projection.subagents
|
||||
.filter((subagent) => subagent.kind === "workflow_agent")
|
||||
.toSorted(
|
||||
(left, right) =>
|
||||
(left.workflowMembership?.agentIndex ?? 0) - (right.workflowMembership?.agentIndex ?? 0),
|
||||
);
|
||||
assert.lengthOf(members, 2, "both workflow members must reach the projection");
|
||||
assert.deepEqual(
|
||||
members.map((member) => [
|
||||
member.title,
|
||||
member.status,
|
||||
member.workflowMembership?.phaseIndex,
|
||||
member.model,
|
||||
member.usage?.totalTokens,
|
||||
]),
|
||||
[
|
||||
["Researcher", "completed", 0, "claude-sonnet-4-6", 400],
|
||||
["Implementer", "running", 1, "claude-opus-4-1", 500],
|
||||
],
|
||||
);
|
||||
// Membership must point at the coordinator that actually reached the
|
||||
// projection, not at an id the adapter invented independently.
|
||||
assert.deepEqual(
|
||||
[...new Set(members.map((member) => member.workflowMembership?.workflowSubagentId))],
|
||||
[coordinator?.id],
|
||||
);
|
||||
|
||||
// The panel groups by these three fields, so pin the values it reads rather
|
||||
// than only the ones the coordinator carries. The derivation itself is
|
||||
// covered in client-runtime; the schema is what joins the two sides, so what
|
||||
// matters here is that the server emits a shape that groups cleanly:
|
||||
// every member claims a declared phase, and no member is left ungrouped.
|
||||
const declaredPhases = new Set((coordinator?.workflow?.phases ?? []).map((phase) => phase.index));
|
||||
assert.deepEqual(
|
||||
members.map((member) => declaredPhases.has(member.workflowMembership?.phaseIndex ?? -1)),
|
||||
[true, true],
|
||||
);
|
||||
assert.lengthOf(
|
||||
projection.subagents.filter(
|
||||
(subagent) => subagent.kind === "workflow_agent" && subagent.workflowMembership === null,
|
||||
),
|
||||
0,
|
||||
"a member without membership would render outside its workflow",
|
||||
);
|
||||
// The coordinator's usage already covers its members, so the panel subtracts
|
||||
// theirs from it. That only stays non-negative if the provider's totals are
|
||||
// carried through unmodified.
|
||||
const memberTotal = members.reduce(
|
||||
(total, member) => total + (member.usage?.totalTokens ?? 0),
|
||||
0,
|
||||
);
|
||||
assert.isAtLeast(coordinator?.usage?.totalTokens ?? 0, memberTotal);
|
||||
|
||||
const assistantTexts = projection.turnItems.flatMap((item) =>
|
||||
item.type === "assistant_message" ? [item.text] : [],
|
||||
);
|
||||
assert.deepEqual(assistantTexts, [
|
||||
"Starting the two-phase workflow.",
|
||||
"claude workflow fixture complete",
|
||||
]);
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import { claudeIdleResumeInput } from "./claude_idle_resume/input.ts";
|
||||
import { assertClaudeIdleResumeOutput } from "./claude_idle_resume/output.ts";
|
||||
import { claudeLocalBashTaskInput } from "./claude_local_bash_task/input.ts";
|
||||
import { assertClaudeLocalBashTaskOutput } from "./claude_local_bash_task/output.ts";
|
||||
import { claudeWorkflowInput } from "./claude_workflow/input.ts";
|
||||
import { assertClaudeWorkflowOutput } from "./claude_workflow/output.ts";
|
||||
import { claudeResultIsErrorInput } from "./claude_result_is_error/input.ts";
|
||||
import { assertClaudeResultIsErrorOutput } from "./claude_result_is_error/output.ts";
|
||||
import { grokSubagentLineageInput } from "./grok_subagent_lineage/input.ts";
|
||||
@@ -118,6 +120,18 @@ export const ORCHESTRATOR_REPLAY_FIXTURES: ReadonlyArray<OrchestratorReplayFixtu
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "claude_workflow",
|
||||
buildInput: claudeWorkflowInput,
|
||||
providers: [
|
||||
{
|
||||
driver: ProviderDriverKind.make("claudeAgent"),
|
||||
transcriptFile: new URL("./claude_workflow/claude_transcript.ndjson", import.meta.url),
|
||||
modelSelection: CLAUDE_MODEL_SELECTION,
|
||||
assertOutput: assertClaudeWorkflowOutput,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "claude_idle_resume",
|
||||
buildInput: claudeIdleResumeInput,
|
||||
|
||||
Reference in new issue
Block a user