When to delegate tasks and work to subagents.
To conserve context space and token usage:
Analyze task dependencies from exec plan
To save context space and token usage, delegate implementation tasks to sub-agents:
Example delegation:
Task: "Implement FileSystemConnector class in src/ingestion/filesystem.py.
Requirements:
- Implement DataConnector interface (see docs/ARCHITECTURE.md and docs/phase<N>_SPEC.md)
- Walk directories recursively
- Filter by file extension
- Extract metadata (size, modified date, path)
- Return IngestedDocument objects
- Include docstrings and type hints
- Handle errors gracefully"
Implement the FileSystemConnector class according to the DataConnector interface.
It should:
- Walk a directory recursively
- Support filtering by file extension
- Extract basic metadata (size, modified date, path)
- Return IngestedDocument objects
Follow the patterns in docs/ARCHITECTURE.md.
Create a utility function for semantic chunking of text documents.
Requirements:
- Respect paragraph boundaries
- Target chunk size of ~500 tokens
- Overlap of ~50 tokens between chunks
- Return chunks with metadata (position, total chunks)
Implement the ChromaDB storage layer.
It should:
- Initialize collections on startup
- Add documents with embeddings and metadata
- Query by similarity with filters
- Handle connection errors gracefully
Here's how the Build Agent should handle a multi-part implementation:
User: Implement the ingestion pipeline with filesystem and markdown connectors.
Agent thinks:
- This involves multiple components
- I'll break it into sub-tasks and delegate each
- After each component, I'll commit
Task 1 (delegate): "Implement base DataConnector interface in src/ingestion/base.py..."
Task 2 (delegate): "Implement FileSystemConnector in src/ingestion/filesystem.py..."
Task 3 (delegate): "Implement MarkdownConnector in src/ingestion/markdown.py..."
Task 4 (delegate): "Write tests for connectors in tests/test_connectors.py..."
# After base interface is implemented:
git add src/ingestion/base.py
git commit -m "feat: add DataConnector base interface"
# After filesystem connector:
git add src/ingestion/filesystem.py
git commit -m "feat: add FileSystemConnector with recursive walking"
# After markdown connector:
git add src/ingestion/markdown.py
git commit -m "feat: add MarkdownConnector with frontmatter parsing"
# After tests:
git add tests/test_connectors.py
git commit -m "test: add unit tests for ingestion connectors"
Document what was completed, decisions made, and commit references where relevant.
When delegating to a sub-agent, use this template:
Implement [component name] in [file path].
CONTEXT:
[Relevant background from architecture docs]
REQUIREMENTS:
- [Specific requirement 1]
- [Specific requirement 2]
- [etc.]
INTERFACE:
[Any interfaces or base classes to implement]
PATTERNS TO FOLLOW:
[Reference existing code patterns]
DELIVERABLES:
- Working implementation with type hints
- Docstrings for public methods
- Error handling with meaningful messages
- [Any specific outputs needed]