-
Notifications
You must be signed in to change notification settings - Fork 16
Pluggable Providers Tasks
Input: Design documents from .speckit/features/103-pluggable-providers/
Prerequisites: plan.md, spec.md, research.md, data-model.md, contracts/provider-protocols.md
Tests: Tests are REQUIRED per constitution principle III (Test-Alongside). Unit tests for each provider, integration tests for factory.
Organization: Tasks grouped by user story to enable independent implementation and testing.
- [P]: Can run in parallel (different files, no dependencies)
- [Story]: Which user story this task belongs to (e.g., US1, US2, US3)
- Include exact file paths in descriptions
All paths relative to agent-brain-server/:
- Source:
agent_brain_server/ - Tests:
tests/
Purpose: Project initialization, new dependencies, and provider package structure
- T001 Add new dependencies to
agent-brain-server/pyproject.toml: cohere, google-generativeai, pyyaml - T002 [P] Create providers package structure in
agent_brain_server/providers/__init__.py - T003 [P] Create embedding subpackage in
agent_brain_server/providers/embedding/__init__.py - T004 [P] Create summarization subpackage in
agent_brain_server/providers/summarization/__init__.py - T005 [P] Create tests directory structure in
tests/unit/providers/
Purpose: Core abstractions and configuration infrastructure that ALL user stories depend on
- T006 [P] Create
EmbeddingProviderTypeenum inagent_brain_server/providers/base.py - T007 [P] Create
SummarizationProviderTypeenum inagent_brain_server/providers/base.py - T008 [P] Create
EmbeddingConfigPydantic model inagent_brain_server/config/provider_config.py - T009 [P] Create
SummarizationConfigPydantic model inagent_brain_server/config/provider_config.py - T010 Create
ProviderSettingstop-level config model inagent_brain_server/config/provider_config.py
- T011 [P] Create
EmbeddingProviderProtocol inagent_brain_server/providers/base.py - T012 [P] Create
SummarizationProviderProtocol inagent_brain_server/providers/base.py - T013 [P] Create
BaseEmbeddingProviderabstract class inagent_brain_server/providers/base.py - T014 [P] Create
BaseSummarizationProviderabstract class inagent_brain_server/providers/base.py
- T015 Create
ProviderErrorexception hierarchy inagent_brain_server/providers/exceptions.py:-
ProviderError(base) ConfigurationErrorAuthenticationErrorProviderNotFoundErrorProviderMismatchErrorRateLimitErrorModelNotFoundError
-
- T016 Create
ProviderRegistryfactory inagent_brain_server/providers/factory.pywith:-
register_embedding_provider()method -
register_summarization_provider()method -
get_embedding_provider()method -
get_summarization_provider()method -
clear_cache()method for testing
-
- T017 [P] Unit test for
EmbeddingConfigvalidation intests/unit/providers/test_config.py - T018 [P] Unit test for
SummarizationConfigvalidation intests/unit/providers/test_config.py - T019 Unit test for
ProviderRegistryfactory intests/unit/providers/test_factory.py
Checkpoint: Foundation ready - core abstractions and factory in place ✅
Goal: Users can switch embedding providers (OpenAI, Ollama, Cohere) via config.yaml
Independent Test: Configure Ollama embeddings in config.yaml, start server, verify embeddings work
- T020 [P] [US1] Unit test for
OpenAIEmbeddingProviderintests/unit/providers/test_openai_embedding.py - T021 [P] [US1] Unit test for
OllamaEmbeddingProviderintests/unit/providers/test_ollama_embedding.py - T022 [P] [US1] Unit test for
CohereEmbeddingProviderintests/unit/providers/test_cohere_embedding.py(provider implemented, tests pending)
- T023 [P] [US1] Implement
OpenAIEmbeddingProviderinagent_brain_server/providers/embedding/openai.py:- Refactor from existing
EmbeddingGeneratorOpenAI code - Implement
EmbeddingProviderprotocol - Support
embed_text(),embed_texts(),get_dimensions() - Model dimension mapping for text-embedding-3-large/small, ada-002
- Refactor from existing
- T024 [P] [US1] Implement
OllamaEmbeddingProviderinagent_brain_server/providers/embedding/ollama.py:- Use OpenAI-compatible client with custom base_url
- Support nomic-embed-text, mxbai-embed-large models
- Implement
EmbeddingProviderprotocol
- T025 [P] [US1] Implement
CohereEmbeddingProviderinagent_brain_server/providers/embedding/cohere.py:- Use Cohere SDK async client
- Support embed-english-v3, embed-multilingual-v3 models
- Implement
EmbeddingProviderprotocol
- T026 [US1] Register embedding providers in
agent_brain_server/providers/embedding/__init__.py - T027 [US1] Add startup logging for embedding provider selection in
agent_brain_server/api/main.py
Checkpoint: User Story 1 complete - embedding providers switchable via config ✅
Goal: Users can switch summarization providers (Anthropic, OpenAI, Gemini, Grok, Ollama) via config
Independent Test: Configure GPT-4o for summarization, index documents, verify summaries generated
- T028 [P] [US2] Unit test for
AnthropicSummarizationProviderintests/unit/providers/test_anthropic_summarization.py - T029 [P] [US2] Unit test for
OpenAISummarizationProviderintests/unit/providers/test_openai_summarization.py(provider implemented, tests pending) - T030 [P] [US2] Unit test for
GeminiSummarizationProviderintests/unit/providers/test_gemini_summarization.py(provider implemented, tests pending) - T031 [P] [US2] Unit test for
GrokSummarizationProviderintests/unit/providers/test_grok_summarization.py(provider implemented, tests pending) - T032 [P] [US2] Unit test for
OllamaSummarizationProviderintests/unit/providers/test_ollama_summarization.py(provider implemented, tests pending)
- T033 [P] [US2] Implement
AnthropicSummarizationProviderinagent_brain_server/providers/summarization/anthropic.py:- Refactor from existing
EmbeddingGeneratorAnthropic code - Implement
SummarizationProviderprotocol - Support
summarize()andgenerate()methods
- Refactor from existing
- T034 [P] [US2] Implement
OpenAISummarizationProviderinagent_brain_server/providers/summarization/openai.py:- Use OpenAI chat completion API
- Implement
SummarizationProviderprotocol
- T035 [P] [US2] Implement
GeminiSummarizationProviderinagent_brain_server/providers/summarization/gemini.py:- Use google-generativeai SDK
- Implement
SummarizationProviderprotocol - Use
generate_content_async()for async support
- T036 [P] [US2] Implement
GrokSummarizationProviderinagent_brain_server/providers/summarization/grok.py:- Use OpenAI client with custom base_url (https://api.x.ai/v1)
- Implement
SummarizationProviderprotocol
- T037 [P] [US2] Implement
OllamaSummarizationProviderinagent_brain_server/providers/summarization/ollama.py:- Use OpenAI-compatible client with local base_url
- Implement
SummarizationProviderprotocol
- T038 [US2] Register summarization providers in
agent_brain_server/providers/summarization/__init__.py - T039 [US2] Add startup logging for summarization provider selection in
agent_brain_server/api/main.py
Checkpoint: User Story 2 complete - summarization providers switchable via config ✅
Goal: Users configure providers via config.yaml without code changes
Independent Test: Create config.yaml, start server, verify configured providers are used
- T040 [P] [US3] Unit test for YAML config loading in
tests/unit/providers/test_config.py(combined in test_config.py) - T041 [P] [US3] Unit test for config validation in
tests/unit/providers/test_config.py(combined in test_config.py) - T042 [US3] Integration test for config loading precedence in
tests/integration/test_provider_config.py
- T043 [US3] Implement
load_provider_settings()function inagent_brain_server/config/provider_config.py:- Load config.yaml from project root
- Support
DOC_SERVE_CONFIGenv var override - Fall back to sensible defaults (OpenAI + Anthropic)
- T044 [US3] Implement config validation with descriptive error messages in
agent_brain_server/config/provider_config.py - T045 [US3] Add config file discovery logic (project root, state dir) in
agent_brain_server/config/provider_config.py - T046 [US3] Update
settings.pyto integrate with provider configuration inagent_brain_server/config/settings.py
Checkpoint: User Story 3 complete - YAML configuration fully functional ✅
Goal: Users can run Agent Brain entirely locally without external API calls
Independent Test: Configure Ollama for both, disconnect internet, verify full functionality
- T047 [P] [US4] Unit test for Ollama-only config validation in
tests/unit/providers/test_offline_config.py - T048 [US4] Integration test for offline operation in
tests/integration/test_offline_operation.py
- T049 [US4] Add Ollama health check in
agent_brain_server/providers/embedding/ollama.py - T050 [US4] Add Ollama health check in
agent_brain_server/providers/summarization/ollama.py - T051 [US4] Skip API key validation when provider is Ollama in
agent_brain_server/config/provider_config.py - T052 [US4] Add clear error messages when Ollama not running in
agent_brain_server/providers/exceptions.py
Checkpoint: User Story 4 complete - fully offline operation works
Goal: API keys are securely managed via environment variables referenced in config
Independent Test: Configure provider with api_key_env: OPENAI_API_KEY, verify key read from env
- T053 [P] [US5] Unit test for api_key_env resolution in
tests/unit/providers/test_api_key_resolution.py - T054 [P] [US5] Unit test for missing API key error in
tests/unit/providers/test_api_key_errors.py - T055 [US5] Integration test for secure key handling in
tests/integration/test_api_key_security.py
- T056 [US5] Implement
resolve_api_key()helper inagent_brain_server/config/provider_config.py:- Read key from environment variable specified in
api_key_env - Raise
AuthenticationErrorif not found - Skip validation for Ollama (no key needed)
- Read key from environment variable specified in
- T057 [US5] Ensure API keys are never logged in
agent_brain_server/providers/base.py - T058 [US5] Add key masking in error messages in
agent_brain_server/providers/exceptions.py
Checkpoint: User Story 5 complete - secure API key management works
Purpose: Integrate providers with existing services
- T059 Refactor
EmbeddingGeneratorinagent_brain_server/indexing/embedding.py:- Remove hard-coded OpenAI client initialization
- Accept
EmbeddingProvidervia dependency injection - Accept
SummarizationProvidervia dependency injection - Delegate to provider instances
- T060 Update
IndexingServiceinagent_brain_server/services/indexing_service.py:- Use
ProviderRegistryto get providers from config - Pass providers to
EmbeddingGenerator
- Use
- T061 Update
QueryServiceinagent_brain_server/services/query_service.py:- Use
ProviderRegistryfor embedding provider
- Use
- T062 Update server startup in
agent_brain_server/api/main.py:- Load provider configuration
- Validate config before starting
- Log active providers
- T063 Create
IndexMetadatamodel inagent_brain_server/models/index_metadata.py - T064 Implement metadata storage/retrieval in
agent_brain_server/storage/metadata_store.py - T065 Add provider mismatch detection on startup in
agent_brain_server/services/indexing_service.py
- T066 Integration test for provider switching in
tests/integration/test_provider_switching.py - T067 Integration test for index metadata validation in
tests/integration/test_index_metadata.py
Checkpoint: All services integrated with pluggable providers
Purpose: Documentation, cleanup, and final validation
- T068 [P] Update quickstart.md with all provider examples in
.speckit/features/103-pluggable-providers/quickstart.md - T069 [P] Add config.yaml.example to project root in
config.yaml.example - T070 [P] Update USER_GUIDE.md with provider configuration section in
docs/USER_GUIDE.md - T071 [P] Update DEVELOPERS_GUIDE.md with provider extension guide in
docs/DEVELOPERS_GUIDE.md - T072 Run
task before-pushto validate all tests pass - T073 Run quickstart.md validation manually
- T074 Update constitution Technology Stack section to include pluggable providers in
.speckit/memory/constitution.md
Phase 1 (Setup) ──────────────────────────────────────────────┐
│
Phase 2 (Foundational) ◄──────────────────────────────────────┘
│
├───► Phase 3 (US1: Embedding Providers) ──────────────────┐
│ │
├───► Phase 4 (US2: Summarization Providers) ──────────────┤
│ │
└───► Phase 5 (US3: YAML Configuration) ───────────────────┤
│
▼
Phase 6 (US4: Offline) ◄───────────────────────────────────┤
│
Phase 7 (US5: API Keys) ◄──────────────────────────────────┤
│
Phase 8 (Integration) ◄────────────────────────────────────┘
│
▼
Phase 9 (Polish)
- US1 (Embedding Providers): Depends on Phase 2 (Foundational) - No dependencies on other stories
- US2 (Summarization Providers): Depends on Phase 2 - No dependencies on other stories
- US3 (YAML Configuration): Depends on Phase 2 - Should be done with US1/US2 for full testing
- US4 (Offline Operation): Depends on US1, US2, US3 (needs Ollama providers and config)
- US5 (API Key Management): Depends on Phase 2 - Can run parallel with US1-US4
Phase 1 (Setup):
# All can run in parallel:
T002, T003, T004, T005Phase 2 (Foundational):
# Config models in parallel:
T006, T007, T008, T009
# Protocols in parallel:
T011, T012, T013, T014
# Tests in parallel:
T017, T018Phase 3 (US1 - Embeddings):
# All tests in parallel:
T020, T021, T022
# All provider implementations in parallel:
T023, T024, T025Phase 4 (US2 - Summarization):
# All tests in parallel:
T028, T029, T030, T031, T032
# All provider implementations in parallel:
T033, T034, T035, T036, T037Phase 5 (US3 - Config):
# Tests in parallel:
T040, T041- Complete Phase 1: Setup
- Complete Phase 2: Foundational (CRITICAL - blocks all stories)
- Complete Phase 3: US1 - Embedding Providers
- Complete Phase 4: US2 - Summarization Providers
- Complete Phase 5: US3 - YAML Configuration
- STOP and VALIDATE: All core provider functionality works
- Deploy/demo if ready
MVP delivers: Configuration-driven provider switching for both embeddings and summarization
- Complete MVP (Phases 1-5)
- Complete Phase 6: US4 - Offline Operation
- Complete Phase 7: US5 - API Key Management
- Complete Phase 8: Service Integration
- Complete Phase 9: Polish
With 3 developers after Phase 2:
- Developer A: US1 (Embedding Providers) → US4 (Offline)
- Developer B: US2 (Summarization Providers) → US5 (API Keys)
- Developer C: US3 (YAML Config) → Phase 8 Integration
| Phase | Description | Task Count | Status |
|---|---|---|---|
| 1 | Setup | 5 | ✅ COMPLETE |
| 2 | Foundational | 14 | ✅ COMPLETE |
| 3 | US1: Embedding Providers | 8 | ✅ COMPLETE (1 test pending) |
| 4 | US2: Summarization Providers | 12 | ✅ COMPLETE (4 tests pending) |
| 5 | US3: YAML Configuration | 7 | ✅ COMPLETE (1 integration test pending) |
| 6 | US4: Offline Operation | 6 | ⏳ NOT STARTED |
| 7 | US5: API Key Management | 6 | ⏳ NOT STARTED |
| 8 | Service Integration | 9 | 🔄 PARTIAL (2/9 done) |
| 9 | Polish | 7 | 🔄 PARTIAL (1/7 done) |
| Total | 74 | MVP Complete |
All core provider functionality implemented:
- 3 embedding providers (OpenAI, Ollama, Cohere)
- 5 summarization providers (Anthropic, OpenAI, Gemini, Grok, Ollama)
- YAML configuration loading with validation
- EmbeddingGenerator refactored to use provider abstraction
- Server startup logging for active providers
- Quality gate passes (338 tests, all linting/typing checks pass)
- US1 (Embedding Providers): 8 tasks
- US2 (Summarization Providers): 12 tasks
- US3 (YAML Configuration): 7 tasks
- US4 (Offline Operation): 6 tasks
- US5 (API Key Management): 6 tasks
- Phase 1: 4 of 5 tasks can run in parallel
- Phase 2: 10 of 14 tasks can run in parallel
- Phase 3: 6 of 8 tasks can run in parallel
- Phase 4: 10 of 12 tasks can run in parallel
- Phase 5: 2 of 7 tasks can run in parallel
- Phase 6: 1 of 6 tasks can run in parallel
- Phase 7: 2 of 6 tasks can run in parallel
- Phase 9: 4 of 7 tasks can run in parallel
- [P] tasks = different files, no dependencies
- [Story] label maps task to specific user story for traceability
- Each user story is independently completable and testable
- Verify tests fail before implementing (Test-Alongside principle)
- Commit after each task or logical group
- Run
task before-pushbefore pushing any changes - Stop at any checkpoint to validate story independently
- Design-Architecture-Overview
- Design-Query-Architecture
- Design-Storage-Architecture
- Design-Class-Diagrams
- GraphRAG-Guide
- Agent-Skill-Hybrid-Search-Guide
- Agent-Skill-Graph-Search-Guide
- Agent-Skill-Vector-Search-Guide
- Agent-Skill-BM25-Search-Guide
Search
Server
Setup
- Pluggable-Providers-Spec
- GraphRAG-Integration-Spec
- Agent-Brain-Plugin-Spec
- Multi-Instance-Architecture-Spec