From cf34bed26f6e63512467dcd407368c35c3668876 Mon Sep 17 00:00:00 2001 From: rUv Date: Tue, 5 Aug 2025 12:38:14 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=96=20Checkpoint:=20Edit=20/workspaces?= =?UTF-8?q?/claude-code-flow/docs/stream-chaining.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/checkpoints/1754397455.json | 1 + .claude/checkpoints/1754397457.json | 1 + docs/stream-chaining.md | 116 ++++++++++++++++++++++++++-- 3 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 .claude/checkpoints/1754397455.json create mode 100644 .claude/checkpoints/1754397457.json diff --git a/.claude/checkpoints/1754397455.json b/.claude/checkpoints/1754397455.json new file mode 100644 index 0000000000..971827d858 --- /dev/null +++ b/.claude/checkpoints/1754397455.json @@ -0,0 +1 @@ +{"branch": "checkpoint/pre-edit-20250805-123735", "file": "/workspaces/claude-code-flow/docs/stream-chaining.md", "timestamp": "2025-08-05T12:37:35Z", "type": "pre-edit", "original_branch": "alpha-85"} diff --git a/.claude/checkpoints/1754397457.json b/.claude/checkpoints/1754397457.json new file mode 100644 index 0000000000..a16c2f3b09 --- /dev/null +++ b/.claude/checkpoints/1754397457.json @@ -0,0 +1 @@ +{"tag": "checkpoint-20250805-123737", "file": "/workspaces/claude-code-flow/docs/stream-chaining.md", "timestamp": "2025-08-05T12:37:37Z", "type": "post-edit", "branch": "alpha-85", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/system-metrics.json | 36 ++++++++++++++++++++++++++++++++ .claude-flow/metrics/task-metrics.json | 6 +++--- .claude/checkpoints/1754397436.json | 1 + .claude/checkpoints/1754397438.json | 1 + claude-flow-wiki | 0 docs/stream-chaining.md | 17 +++++++++++++-- 7 files changed, 57 insertions(+), 6 deletions(-) "} diff --git a/docs/stream-chaining.md b/docs/stream-chaining.md index 361955f86d..4e80ce3a96 100644 --- a/docs/stream-chaining.md +++ b/docs/stream-chaining.md @@ -264,15 +264,117 @@ if (inputStream && claudeProcess.stdin) { 4. **Monitor performance**: Stream chaining reduces latency but increases complexity 5. **Test incrementally**: Build chains step by step, testing each link +## 🔍 Troubleshooting + +### Common Issues + +1. **"Unexpected end of JSON input"** + - Cause: Malformed JSON in the stream + - Fix: Ensure all agents output valid stream-json format + +2. **"No input received"** + - Cause: Dependency task failed or produced no output + - Fix: Check task execution logs, ensure dependency succeeded + +3. **"Context seems lost between agents"** + - Cause: Missing `--input-format stream-json` flag + - Fix: Verify Claude Flow is adding the flag (check with --verbose) + +4. **Performance degradation** + - Cause: Large context accumulation + - Fix: Use `--max-turns` to limit context size + +### Debugging Commands + +```bash +# Debug stream output +./claude-flow automation mle-star --dataset data.csv --target label --claude --verbose + +# Save stream for analysis +./claude-flow automation run-workflow workflow.json --claude --output-format stream-json 2>&1 | tee debug.log + +# Validate stream format +cat debug.log | jq -c 'select(.type)' | head -20 +``` + +## 🌟 Real-World Workflow Examples + +### Software Development Pipeline + +```json +{ + "name": "Full-Stack Development Workflow", + "tasks": [ + { + "id": "requirements", + "name": "Analyze Requirements", + "assignTo": "analyst", + "claudePrompt": "Analyze the requirements in docs/requirements.md" + }, + { + "id": "design", + "name": "System Design", + "assignTo": "architect", + "depends": ["requirements"], + "claudePrompt": "Based on the requirements analysis, create a system design" + }, + { + "id": "backend", + "name": "Backend Implementation", + "assignTo": "backend-dev", + "depends": ["design"], + "claudePrompt": "Implement the backend based on the system design" + }, + { + "id": "frontend", + "name": "Frontend Implementation", + "assignTo": "frontend-dev", + "depends": ["design"], + "claudePrompt": "Implement the frontend based on the system design" + }, + { + "id": "integration", + "name": "Integration & Testing", + "assignTo": "tester", + "depends": ["backend", "frontend"], + "claudePrompt": "Integrate and test the complete application" + } + ] +} +``` + +### Research Paper Analysis Pipeline + +```bash +# Extract key findings +claude -p --output-format stream-json \ + "Extract key findings from the paper at papers/research.pdf" | \ +# Synthesize with existing knowledge +claude -p --input-format stream-json --output-format stream-json \ + "Compare these findings with current literature in the field" | \ +# Generate implementation ideas +claude -p --input-format stream-json --output-format stream-json \ + "Suggest practical implementations of these findings" | \ +# Create action plan +claude -p --input-format stream-json \ + "Create a detailed action plan for implementing these ideas" +``` + ## 💡 Key Insight **Stream chaining** turns Claude from a stateless prompt executor into a programmable agent pipeline. It's how you move from chat to computation, enabling complex multi-agent workflows that maintain context and build upon each other's work in real-time. -## Future Enhancements +This technology fundamentally changes how we think about AI automation: +- **From**: Sequential, isolated prompts with context loss +- **To**: Continuous, connected workflows with full context preservation -- Support for multiple input streams (merge/join operations) -- Conditional chaining based on output content -- Stream filtering and transformation middleware -- Parallel stream processing with fan-out/fan-in patterns -- Built-in retry and error recovery mechanisms -- Stream replay and debugging tools \ No newline at end of file +## 🚧 Future Enhancements + +- **Multi-stream merge**: Support for multiple input streams (merge/join operations) +- **Conditional routing**: Dynamic chaining based on output content +- **Stream middleware**: Filtering and transformation between agents +- **Parallel patterns**: Fan-out/fan-in for parallel processing +- **Error recovery**: Built-in retry and fallback mechanisms +- **Debug tools**: Stream replay and step-through debugging +- **Visual monitoring**: Real-time visualization of stream flow +- **Performance analytics**: Detailed metrics for each chain segment \ No newline at end of file