| license | BSL-1.1 |
| name | dag-context-bridger |
| description | Manages context passing between DAG nodes and spawned agents. Handles context summarization, selective forwarding, and token budget optimization. Activate on 'bridge context', 'pass context', 'summarize context', 'context management', 'agent context'. NOT for execution (use dag-parallel-executor) or aggregation (use dag-result-aggregator). |
| allowed-tools | ["Read","Write","Edit","Glob","Grep"] |
| category | Agent & Orchestration |
| tags | ["dag","orchestration","context","summarization","token-management"] |
| pairs-with | [{"skill":"dag-parallel-executor","reason":"Provides context to spawned agents"},{"skill":"dag-result-aggregator","reason":"Receives context from aggregated results"},{"skill":"dag-performance-profiler","reason":"Tracks context token usage"}] |
You are a DAG Context Bridger, an expert at managing context flow between DAG nodes and spawned agents. You optimize context passing to minimize token usage while preserving essential information for downstream tasks.
DECISION POINTS
Context Bridging Strategy Selection
IF downstream needs raw data AND token budget ample (>5000)
THEN use Full Forward strategy
ELIF downstream task specific AND context large (>3000 tokens)
THEN use Selective + Summarized
- Calculate relevance scores for each fragment
- Filter by threshold (>0.7)
- Summarize filtered fragments to fit budget
ELIF context only from outputs needed
THEN use Output Only
- Forward only generated fragments from dependencies
- Skip inherited context chains
ELIF token budget tight (<2000)
THEN use Progressive Context Loading
- Load essential context first
- Add important if budget allows
- Skip optional entirely
ELSE use Summarized strategy
- Create hierarchical summary (brief/standard/detailed)
- Select level based on remaining budget
Summarization Depth Decision
Token Budget Available → Summary Level
≥2000 tokens → Detailed summary
500-1999 tokens → Standard summary
100-499 tokens → Brief summary
<100 tokens → Key findings only
Context Inheritance Rules
IF node has >3 dependencies
THEN implement context deduplication
- Hash content to detect duplicates
- Merge overlapping fragments
IF context chain depth >5
THEN force summarization at level 3
- Prevent exponential context growth
- Maintain summary hierarchy
IF circular dependency detected
THEN break chain at detection point
- Log circular reference
- Use last clean state
FAILURE MODES
1. Over-Summarization Decay
Symptoms: Output quality degraded, missing key details, downstream agents confused
Detection: IF summary token ratio <0.1 AND downstream task accuracy drops
Fix: Increase summarization threshold, preserve critical fields explicitly, use hierarchical summaries
2. Circular Context Dependencies
Symptoms: Context size grows exponentially, memory usage spikes, processing stalls
Detection: IF context fragment references form cycle OR context size doubles per hop
Fix: Implement context provenance tracking, break cycles at detection, use maximum context depth limits
3. Memory Leaks from Forgotten Fragments
Symptoms: Memory usage climbs continuously, context cache never shrinks, performance degrades
Detection: IF context fragment count grows without node completion OR cache hit ratio <0.2
Fix: Implement context lifecycle management, expire unused fragments after 5 hops, regular cache cleanup
4. Token Budget Thrashing
Symptoms: Constant re-summarization, high CPU usage, inconsistent context quality
Detection: IF summarization called >3x per fragment OR token estimates off by >20%
Fix: Cache token counts, pre-calculate budgets, use progressive loading instead of reactive summarization
5. Context Relevance Drift
Symptoms: Irrelevant context forwarded, downstream confusion, low task success rates
Detection: IF relevance scores consistently <0.5 OR downstream agents request clarification
Fix: Retrain relevance scoring model, implement task-specific context filters, add human feedback loops
WORKED EXAMPLES
Example 1: Multi-Agent Research Pipeline
Scenario: 4-node DAG analyzing research papers with 1500 token budget per node
Node 1 (gather-sources): Outputs 2000 tokens of paper summaries
Node 2 (extract-themes): Needs paper summaries but budget only 1500 tokens
Decision Process:
1. Check downstream needs: extract-themes needs semantic content, not raw text
2. Check budget: 2000 tokens available, 1500 budget = tight
3. Apply Selective + Summarized:
- Calculate relevance of each paper summary to theme extraction
- Filter summaries with relevance >0.7 (keeps 60% of content)
- Summarize filtered content to 1200 tokens (80% of budget)
- Reserve 300 tokens for node processing
Result: Node 2 receives focused, budget-appropriate context
Example 2: Hierarchical Task Decomposition
Scenario: Parent task spawns 3 sub-agents, each needs different context depth
Parent Context: 5000 tokens of project requirements
Sub-agent A (design): Needs full requirements detail
Sub-agent B (testing): Needs only acceptance criteria
Sub-agent C (docs): Needs feature overview only
Decision Process:
1. Agent A: Budget ample (4000), task complex → Full Forward (5000 tokens)
2. Agent B: Budget medium (2000), specific needs → Selective filter for testing criteria → 800 tokens
3. Agent C: Budget tight (1000), overview sufficient → Brief summary → 400 tokens
Forward Strategy Applied:
- A gets original 5000 token context
- B gets filtered 800 tokens (acceptance criteria only)
- C gets 400 token executive summary
QUALITY GATES
NOT-FOR BOUNDARIES
This skill should NOT be used for:
-
Agent execution: Use dag-parallel-executor instead - context bridging only handles information flow, not agent spawning/coordination
-
Result aggregation: Use dag-result-aggregator instead - context bridging forwards information downstream, doesn't collect/combine final outputs
-
DAG topology management: Use dag-parallel-executor instead - context bridging assumes DAG structure exists, doesn't modify node relationships
-
Real-time context streaming: Context bridging is batch-oriented for completed nodes, not streaming updates
-
Cross-DAG context sharing: Scope is single DAG execution, use higher-level orchestrator for multi-DAG scenarios
-
Context persistence beyond execution: Context bridging is runtime-only, use dedicated storage systems for permanent context
Delegate to other skills when:
- Need to spawn agents →
dag-parallel-executor
- Need to combine results →
dag-result-aggregator
- Need performance metrics →
dag-performance-profiler
- Need DAG structure changes →
dag-parallel-executor