How the Five Parallel Sub-Agents Divide Work in cangjie-skill: Architecture and Implementation
The cangjie-skill repository distributes prompt processing across five specialized parallel sub-agents—Principle, Glossary, Framework, Counter-Example, and Case extractors—each handling a distinct extraction task simultaneously.
The cangjie-skill project implements a multi-agent extraction system that breaks complex inputs into parallelizable units. By dividing work among five purpose-built sub-agents, the architecture avoids single-agent context limits while producing richly structured outputs.
The Five Parallel Sub-Agents in cangjie-skill
Each sub-agent operates as an independent extractor with a narrowly defined responsibility. The division of labor follows a facet-based approach, where every agent extracts one dimension of meaning from the source material.
| Sub-Agent | Responsibility | Source File |
|---|---|---|
| Principle Extractor | Identifies underlying principles, rules, and doctrines | extractors/principle-extractor.md |
| Glossary Extractor | Extracts and formats key terms with their definitions | extractors/glossary-extractor.md |
| Framework Extractor | Detects structural models, schemata, and frameworks | extractors/framework-extractor.md |
| Counter-Example Extractor | Finds contradicting examples and challenging arguments | extractors/counter-example-extractor.md |
| Case Extractor | Extracts concrete case studies and real-world illustrations | extractors/case-extractor.md |
These extractors are invoked simultaneously by the stage-1 parallel extract workflow documented in methodology/02-stage1-parallel-extract.md.
How the Parallel Extraction Workflow Operates
The main driver orchestrates the five sub-agents through a three-phase process:
- Chunking — Splits large prompts into processable segments when necessary
- Dispatch — Forwards each chunk to all five extractors concurrently
- Merging — Combines individual outputs into a unified structured response
Because agents run in parallel, total latency equals the slowest extractor's runtime rather than the sum of all five. This design also provides fault isolation: if one extractor fails, the others continue contributing, and the merge step handles missing sections gracefully.
Implementation Pattern for Parallel Sub-Agent Execution
The repository uses a thread-based concurrency model to launch extractors. Below is representative pseudocode reflecting the actual implementation pattern:
from concurrent.futures import ThreadPoolExecutor, as_completed
from extractors import (
principle_extractor,
glossary_extractor,
framework_extractor,
counter_example_extractor,
case_extractor,
)
def run_parallel_extractors(prompt: str) -> dict:
# Map each extractor function to a human-readable label
extractors = {
"principle": principle_extractor,
"glossary": glossary_extractor,
"framework": framework_extractor,
"counter_example": counter_example_extractor,
"case": case_extractor,
}
results = {}
# Execute all extractors concurrently
with ThreadPoolExecutor(max_workers=len(extractors)) as executor:
future_to_name = {
executor.submit(func, prompt): name for name, func in extractors.items()
}
for future in as_completed(future_to_name):
name = future_to_name[future]
try:
results[name] = future.result()
except Exception as exc:
# If one extractor fails we still keep the others
results[name] = f"Error: {exc}"
return results
The function returns a dictionary keyed by sub-agent name. A separate assembly step (elsewhere in the codebase) stitches these pieces into the final skill output.
Key Source Files for Understanding the Division of Work
| File | Purpose |
|---|---|
SKILL.md |
High-level skill description including parallel extraction stage |
methodology/02-stage1-parallel-extract.md |
Chunking strategy and extractor orchestration details |
extractors/principle-extractor.md |
Prompt template for Principle Extractor |
extractors/glossary-extractor.md |
Prompt template for Glossary Extractor |
extractors/framework-extractor.md |
Prompt template for Framework Extractor |
extractors/counter-example-extractor.md |
Prompt template for Counter-Example Extractor |
extractors/case-extractor.md |
Prompt template for Case Extractor |
Performance and Reliability Characteristics
The parallel sub-agent architecture in cangjie-skill delivers two primary operational benefits:
- Latency reduction — Wall-clock time capped at slowest single extractor
- Graceful degradation — Partial results preserved even when individual agents fail
This design pattern suits large or complex inputs where monolithic extraction would exhaust context windows or produce incomplete analysis.
Summary
- The cangjie-skill repository employs five parallel sub-agents to divide extraction work: Principle, Glossary, Framework, Counter-Example, and Case extractors.
- Each sub-agent is defined in its own
extractors/file with specialized prompt templates. - The
methodology/02-stage1-parallel-extract.mdworkflow handles chunking, dispatch, and result merging. - Parallel execution uses
ThreadPoolExecutorwith fault-tolerant error handling. - The architecture minimizes latency and ensures robust output even with partial agent failures.
Frequently Asked Questions
What happens if one of the five parallel sub-agents fails in cangjie-skill?
The system continues processing. As shown in the implementation pattern, exceptions are caught per-extractor and stored as error strings in the results dictionary. The final merge step can handle missing or errored sections without discarding valid output from functioning agents.
Why five sub-agents specifically rather than more or fewer?
The five extractor types correspond to distinct epistemological facets: principles (rules), glossary (terminology), frameworks (structure), counter-examples (critical perspective), and cases (concrete illustration). This decomposition provides comprehensive coverage without fragmentation that would complicate merging.
How does cangjie-skill handle prompts exceeding a single extractor's context limit?
The methodology/02-stage1-parallel-extract.md workflow implements chunking—splitting large inputs into segments, running extractors against each segment, and deduplicating or reconciling results during the merge phase.
Where is the parallel orchestration logic actually implemented?
The coordination logic resides in the methodology documentation and associated driver code referenced from SKILL.md. The extractor definitions themselves are prompt templates in extractors/*.md files, while the execution follows the ThreadPoolExecutor pattern demonstrated above.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →