mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
3.2 KiB
3.2 KiB
Stream-JSON Chaining in Claude Flow
Overview
Stream-JSON chaining enables Claude instances to pipe their outputs directly to other Claude instances, creating a seamless workflow where agents can build upon each other's work without intermediate storage.
How It Works
When tasks have dependencies and stream-json output format is enabled, Claude Flow automatically:
- Captures the stdout from the first agent
- Pipes it directly to the stdin of the dependent agent
- Adds
--input-format stream-jsonflag to the receiving agent - Maintains the stream connection throughout execution
Example Flow
Agent A (analyzer) → stdout (stream-json) → stdin → Agent B (processor) → stdout → stdin → Agent C (reporter)
Enabling Stream Chaining
Default Behavior
Stream chaining is enabled by default when using:
- Non-interactive mode (
--non-interactiveor default for mle-star) - Stream-json output format (
--output-format stream-json) - Tasks with dependencies
Commands
# MLE-STAR with automatic chaining
./claude-flow automation mle-star --dataset data.csv --target label --claude --output-format stream-json
# Custom workflow with chaining
./claude-flow automation run-workflow workflow.json --claude --non-interactive --output-format stream-json
# Disable chaining (agents run independently)
./claude-flow automation mle-star --dataset data.csv --target label --claude --output-format stream-json --no-chaining
Benefits
- Context Preservation: Full conversation history flows between agents
- Efficiency: No intermediate file I/O required
- Real-time Processing: Streaming output enables immediate processing
- Memory Efficiency: No need to store large intermediate results
Implementation Details
Task Dependencies
Tasks must declare dependencies to enable chaining:
{
"tasks": [
{
"id": "task1",
"name": "Analyze Data",
"assignTo": "agent1"
},
{
"id": "task2",
"name": "Process Results",
"assignTo": "agent2",
"depends": ["task1"] // This enables chaining from task1
}
]
}
Agent Prompts
When chaining is enabled, agents should be aware they may receive input:
{
"claudePrompt": "You are receiving analysis results from the previous agent via stream-json. Process these insights and continue the chain..."
}
Console Output
Look for these indicators:
🔗 Enabling stream chaining from task1 to task2🔗 Chaining: Piping output from previous agent to Agent Name
Manual Chaining
You can also manually chain Claude instances:
# Traditional piping
claude --print --output-format stream-json "Task 1" | \
claude --print --input-format stream-json --output-format stream-json "Task 2" | \
claude --print --input-format stream-json "Task 3"
Limitations
- Only works with
stream-jsonoutput format - Requires non-interactive mode
- Dependencies determine chaining order
- Currently chains from the last dependency if multiple exist
Future Enhancements
- Support for multiple input streams (merge/join)
- Conditional chaining based on output
- Stream filtering and transformation
- Parallel stream processing