Enhanced Streaming Feature
Status: 🟢 In-use Category: Features & Enhancements Date: October 22, 2024
Overview
The Enhanced Streaming feature provides intelligent routing for agent queries with three execution modes:
- DIRECT - Single sub-agent streaming (fastest, minimal latency)
- PARALLEL - Multiple sub-agents streaming in parallel (efficient aggregation)
- COMPLEX - Deep Agent orchestration (intelligent reasoning)
Feature Flag
Environment Variable
ENABLE_ENHANCED_STREAMING=true|false
- Default:
true(enabled) - Location:
docker-compose.dev.yaml→platform-engineer-p2pservice - Set in
.env: Override withENABLE_ENHANCED_STREAMING=falseto disable
Behavior
When Enabled (true)
Queries are analyzed and routed intelligently:
┌─────────────────────────────────────────────────┐
│ Query: "show me komodor clusters" │
│ ↓ │
│ Router detects: 1 agent mentioned │
│ ↓ │
│ DIRECT MODE: Stream from Komodor │
│ Result: Token-by-token streaming ⚡️ │
└─────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────┐
│ Query: "list github repos and komodor clusters"│
│ ↓ │
│ Router detects: 2 agents, no orchestration │
│ ↓ │
│ PARALLEL MODE: Stream from both agents │
│ Result: Aggregated results with sources 🌊 │
└─────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────┐
│ Query: "analyze clusters and create tickets" │
│ ↓ │
│ Router detects: orchestration keywords │
│ ↓ │
│ COMPLEX MODE: Use Deep Agent │
│ Result: Intelligent multi-step orchestration 🧠│
└─────────────────────────────────────────────────┘
When Disabled (false)
All queries go through Deep Agent (original behavior):
- Provides intelligent orchestration for all queries
- No direct streaming optimization
- Higher latency but consistent reasoning path
Routing Logic
DIRECT Mode Triggers
- Single agent mentioned in query
- Examples:
- "show me komodor clusters"
- "list github repositories"
- "get weather for Seattle"
PARALLEL Mode Triggers
- Multiple agents mentioned
- NO orchestration keywords
- Examples:
- "show me github repos and komodor clusters"
- "list jira tickets and github issues"
- "get weather and backstage services"
COMPLEX Mode Triggers
- No specific agent mentioned, OR
- Multiple agents with orchestration keywords
- Orchestration keywords:
analyze,compare,if,thencreate,update,based ondepending on,which,that have
- Examples:
- "analyze komodor clusters and create jira tickets if any are failing"
- "compare github stars to confluence documentation quality"
- "what is the status of our platform?" (no specific agent)
Performance Characteristics
| Mode | Streaming | Latency | Best For |
|---|---|---|---|
| DIRECT | ✅ Token-by-token | ~100ms to first token | Single-agent queries |
| PARALLEL | ✅ Aggregated | ~200ms (parallel) | Multi-agent data gathering |
| COMPLEX | ❌ Blocked | ~2-5s | Intelligent orchestration |
Usage Examples
Enable Feature (Default)
# In .env or docker-compose.dev.yaml
ENABLE_ENHANCED_STREAMING=true
docker compose -f docker-compose.dev.yaml restart platform-engineer-p2p
Disable Feature
# In .env
ENABLE_ENHANCED_STREAMING=false
docker compose -f docker-compose.dev.yaml restart platform-engineer-p2p
Verify Status
docker logs platform-engineer-p2p 2>&1 | grep "Enhanced streaming"
Expected output:
🎛️ Enhanced streaming: ENABLED
or
🎛️ Enhanced streaming: DISABLED
Testing
Test DIRECT Mode
curl -X POST http://localhost:8000 \
-H "Content-Type: application/json" \
-d '{
"jsonrpc":"2.0",
"id":"test-direct",
"method":"message/send",
"params":{
"message":{
"role":"user",
"kind":"message",
"message_id":"msg-direct",
"parts":[{"kind":"text","text":"show me komodor clusters"}]
}
}
}'
Expected logs:
🎯 Routing decision: direct - Direct streaming from komodor
🚀 DIRECT MODE: Streaming from komodor at http://agent-komodor-p2p:8000
Test PARALLEL Mode
curl -X POST http://localhost:8000 \
-H "Content-Type: application/json" \
-d '{
"jsonrpc":"2.0",
"id":"test-parallel",
"method":"message/send",
"params":{
"message":{
"role":"user",
"kind":"message",
"message_id":"msg-parallel",
"parts":[{"kind":"text","text":"list github repos and komodor clusters"}]
}
}
}'
Expected logs:
🎯 Routing decision: parallel - Parallel streaming from github, komodor
🌊 PARALLEL MODE: Streaming from github, komodor
🌊🌊 Parallel streaming from 2 sub-agents
Test COMPLEX Mode
curl -X POST http://localhost:8000 \
-H "Content-Type: application/json" \
-d '{
"jsonrpc":"2.0",
"id":"test-complex",
"method":"message/send",
"params":{
"message":{
"role":"user",
"kind":"message",
"message_id":"msg-complex",
"parts":[{"kind":"text","text":"analyze clusters and create tickets"}]
}
}
}'
Expected logs:
🎯 Routing decision: complex - Query requires orchestration across 2 agents
(Falls through to Deep Agent, no DIRECT/PARALLEL logs)
Implementation Details
Files Modified
-
agent_executor.py- Added
RoutingTypeenum - Added
RoutingDecisiondataclass - Added
_route_query()method - Added
_stream_from_multiple_agents()method - Modified
execute()to check feature flag - Feature flag read from
ENABLE_ENHANCED_STREAMINGenv var
- Added
-
docker-compose.dev.yaml- Added
ENABLE_ENHANCED_STREAMINGtoplatform-engineer-p2penvironment - Default:
${ENABLE_ENHANCED_STREAMING:-true}
- Added
Architecture
┌────────────────────────────────────────────────────────────┐
│ Client Query │
│ ↓ │
│ Feature Flag Check │
│ │ │
│ ├─ ENABLED ────→ Intelligent Router │
│ │ │ │
│ │ ├─ DIRECT ──→ Single Agent │
│ │ ├─ PARALLEL → Multiple Agents │
│ │ └─ COMPLEX ─→ Deep Agent │
│ │ │
│ └─ DISABLED ───→ Deep Agent (all queries) │
└────────────────────────────────────────────────────────────┘
Troubleshooting
Feature Not Working
-
Check feature flag status:
docker logs platform-engineer-p2p 2>&1 | grep "Enhanced streaming" -
Verify environment variable:
docker inspect platform-engineer-p2p | grep ENABLE_ENHANCED_STREAMING -
Restart container:
docker compose -f docker-compose.dev.yaml restart platform-engineer-p2p
Routing Not as Expected
Enable debug logging to see routing decisions:
docker logs platform-engineer-p2p 2>&1 | grep "🎯"
Fallback to Deep Agent
If DIRECT or PARALLEL modes fail, the system automatically falls back to Deep Agent:
docker logs platform-engineer-p2p 2>&1 | grep "falling back"
Related Documentation
- Streaming Architecture - Technical deep dive
- A2A Intermediate States - Tool visibility implementation
Future Enhancements
- LLM-based routing (use GPT-4o-mini for intelligent routing decisions)
- Streaming commentary (supervisor injects status updates during parallel execution)
- Event bus architecture (fully async orchestration)
- Per-agent routing configuration (override routing for specific agents)
- Query complexity scoring (automatic threshold-based routing)