feat(knowledge): global budget, rate limit, source cap, and configurable extraction model - #2468
Conversation
Opus 4.8 Review — ✅ no blocking findingsReviewed Review detailsNo blocking findings. FINDING — src/kiro_crew/knowledge/llm_pool.py:511-516 — the pool-size override applies to every [OPUS-REVIEWED] a2c4738 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsFINDING -- src/kiro_crew/knowledge/ingestion.py:95 -- concurrent waiters all execute False positive or not applicable? A repository writer can comment: |
Design Review (Fable 5) — 🟡 CONCERNSAdvisory design-level review of Design-Verdict: CONCERNS Right shape (global caps over per-source caps), but the "hard cap across ALL sources" isn't, and Watch
Suggestions
[DESIGN-REVIEWED] a2c4738 |
d82ab15 to
886337b
Compare
886337b to
9db7d91
Compare
9db7d91 to
5ffe776
Compare
5ffe776 to
e613442
Compare
e613442 to
6cf31db
Compare
UX Review (Fable 5) — ⏭️ skippedRevision |
…ble extraction model The per-source chunk budgets (auto_ingest_chunk_budget, folder_ingest_chunk_budget) bound cost per folder per sweep, but with many directories registered the total work per sweep = N × per-source budget -- causing LLM pool saturation, embedding backlogs, and gateway stalls (#2175, #2336, #2448). Add five new KnowledgeConfig fields: - sweep_chunk_budget (default 500): hard cap on total chunks across ALL sources in one watcher sweep. Once reached, remaining sources defer to next sweep. - max_sources (default 50): cap on registered source count. Auto-discovery paths stop registering once the cap is reached. - embed_rate_limit (default 120/min): token-bucket throttle on embedding generation, preventing CPU/memory saturation from parallel embed batches. - extraction_model (default empty = agent.model): extraction LLM is no longer hardcoded to claude-haiku-4.5; it uses the user's default model, overridable. - extraction_pool_size (default 3): configurable concurrent extraction workers. All five are live-reloaded (no restart needed except pool size) and exposed in the Settings PATCH schema. 0 = unbounded for all numeric fields. Implementation: - watcher._scan() tracks chunks_used across all folder sources, breaking when the global budget is exhausted - folder_watcher.scan_source() reports chunks_ingested in stats - store.create_auto_source_unless_dismissed() enforces max_sources atomically - EmbedRateLimiter token bucket in ingestion.py, called from _embed_item() - _install_knowledge_agent() reads extraction_model from config - LLMPool.start() reads extraction_pool_size from config - handlers/core.py allows PATCH for all 5 new keys Tests: 24 new tests covering config defaults, rate limiter, source cap, sweep budget, pool size config, and extraction model resolution.
af578d0 to
a2c4738
Compare
Add a dedicated Settings tab to the Knowledge page exposing 5 ingestion config fields: per-source chunk limit, max sources, embedding rate limit, extraction model (dropdown), and extraction pool size. - New SettingsTab.tsx component with commit-on-blur number inputs and model dropdown using useAvailableModels() - Knowledge index.tsx gains 4th tab (list | graph | sources | settings) - Remove entire Knowledge Library section from Settings → Chat panel (auto-ingest toggles remain config-only for power users) - i18n: 18 new keys across 14 locales + en-XA pseudolocale - Remove obsolete ChatPanel.knowledgeAutoIngest test file - Remove dead Knowledge Library test block from SettingsChatPanelCoverage - Update deadKeys baseline (21 → 31) for removed ChatPanel keys Closes the frontend follow-up from PR #2468.
Add a dedicated Settings tab to the Knowledge page exposing 5 ingestion config fields: per-source chunk limit, max sources, embedding rate limit, extraction model (dropdown), and extraction pool size. - New SettingsTab.tsx component with commit-on-blur number inputs and model dropdown using useAvailableModels() - Knowledge index.tsx gains 4th tab (list | graph | sources | settings) - Remove entire Knowledge Library section from Settings → Chat panel (auto-ingest toggles remain config-only for power users) - i18n: 18 new keys across 14 locales + en-XA pseudolocale - Remove obsolete ChatPanel.knowledgeAutoIngest test file - Remove dead Knowledge Library test block from SettingsChatPanelCoverage - Update deadKeys baseline (21 → 31) for removed ChatPanel keys Closes the frontend follow-up from PR #2468.
Add a dedicated Settings tab to the Knowledge page exposing 5 ingestion config fields: per-source chunk limit, max sources, embedding rate limit, extraction model (dropdown), and extraction pool size. - New SettingsTab.tsx component with commit-on-blur number inputs and model dropdown using useAvailableModels() - Knowledge index.tsx gains 4th tab (list | graph | sources | settings) - Remove entire Knowledge Library section from Settings → Chat panel (auto-ingest toggles remain config-only for power users) - i18n: 18 new keys across 14 locales + en-XA pseudolocale - Remove obsolete ChatPanel.knowledgeAutoIngest test file - Remove dead Knowledge Library test block from SettingsChatPanelCoverage - Update deadKeys baseline (21 → 31) for removed ChatPanel keys Closes the frontend follow-up from PR #2468.
Add a dedicated Settings tab to the Knowledge page exposing 5 ingestion config fields: per-source chunk limit, max sources, embedding rate limit, extraction model (dropdown), and extraction pool size. - New SettingsTab.tsx component with commit-on-blur number inputs and model dropdown using useAvailableModels() - Knowledge index.tsx gains 4th tab (list | graph | sources | settings) - Remove entire Knowledge Library section from Settings → Chat panel (auto-ingest toggles remain config-only for power users) - i18n: 18 new keys across 14 locales + en-XA pseudolocale - Remove obsolete ChatPanel.knowledgeAutoIngest test file - Remove dead Knowledge Library test block from SettingsChatPanelCoverage - Update deadKeys baseline (21 → 31) for removed ChatPanel keys Closes the frontend follow-up from PR #2468.
Add a dedicated Settings tab to the Knowledge page exposing 5 ingestion config fields: per-source chunk limit, max sources, embedding rate limit, extraction model (dropdown), and extraction pool size. - New SettingsTab.tsx component with commit-on-blur number inputs and model dropdown using useAvailableModels() - Knowledge index.tsx gains 4th tab (list | graph | sources | settings) - Remove entire Knowledge Library section from Settings → Chat panel (auto-ingest toggles remain config-only for power users) - i18n: 18 new keys across 14 locales + en-XA pseudolocale - Remove obsolete ChatPanel.knowledgeAutoIngest test file - Remove dead Knowledge Library test block from SettingsChatPanelCoverage - Update deadKeys baseline (21 → 31) for removed ChatPanel keys Closes the frontend follow-up from PR #2468.
Add a dedicated Settings tab to the Knowledge page exposing 5 ingestion config fields: per-source chunk limit, max sources, embedding rate limit, extraction model (dropdown), and extraction pool size. - New SettingsTab.tsx component with commit-on-blur number inputs and model dropdown using useAvailableModels() - Knowledge index.tsx gains 4th tab (list | graph | sources | settings) - Remove entire Knowledge Library section from Settings → Chat panel (auto-ingest toggles remain config-only for power users) - i18n: 18 new keys across 14 locales + en-XA pseudolocale - Remove obsolete ChatPanel.knowledgeAutoIngest test file - Remove dead Knowledge Library test block from SettingsChatPanelCoverage - Update deadKeys baseline (21 → 31) for removed ChatPanel keys Closes the frontend follow-up from PR #2468.
Add a dedicated Settings tab to the Knowledge page exposing 5 ingestion config fields: per-source chunk limit, max sources, embedding rate limit, extraction model (dropdown), and extraction pool size. - New SettingsTab.tsx component with commit-on-blur number inputs and model dropdown using useAvailableModels() - Knowledge index.tsx gains 4th tab (list | graph | sources | settings) - Remove entire Knowledge Library section from Settings → Chat panel (auto-ingest toggles remain config-only for power users) - i18n: 18 new keys across 14 locales + en-XA pseudolocale - Remove obsolete ChatPanel.knowledgeAutoIngest test file - Remove dead Knowledge Library test block from SettingsChatPanelCoverage - Update deadKeys baseline (21 → 31) for removed ChatPanel keys Closes the frontend follow-up from PR #2468.
Add a dedicated Settings tab to the Knowledge page exposing 5 ingestion config fields: per-source chunk limit, max sources, embedding rate limit, extraction model (dropdown), and extraction pool size. - New SettingsTab.tsx component with commit-on-blur number inputs and model dropdown using useAvailableModels() - Knowledge index.tsx gains 4th tab (list | graph | sources | settings) - Remove entire Knowledge Library section from Settings → Chat panel (auto-ingest toggles remain config-only for power users) - i18n: 18 new keys across 14 locales + en-XA pseudolocale - Remove obsolete ChatPanel.knowledgeAutoIngest test file - Remove dead Knowledge Library test block from SettingsChatPanelCoverage - Update deadKeys baseline (21 → 31) for removed ChatPanel keys Closes the frontend follow-up from PR #2468.
Add a dedicated Settings tab to the Knowledge page exposing 5 ingestion config fields: per-source chunk limit, max sources, embedding rate limit, extraction model (dropdown), and extraction pool size. - New SettingsTab.tsx component with commit-on-blur number inputs and model dropdown using useAvailableModels() - Knowledge index.tsx gains 4th tab (list | graph | sources | settings) - Remove entire Knowledge Library section from Settings → Chat panel (auto-ingest toggles remain config-only for power users) - i18n: 18 new keys across 14 locales + en-XA pseudolocale - Remove obsolete ChatPanel.knowledgeAutoIngest test file - Remove dead Knowledge Library test block from SettingsChatPanelCoverage - Update deadKeys baseline (21 → 31) for removed ChatPanel keys Closes the frontend follow-up from PR #2468.
Add a dedicated Settings tab to the Knowledge page exposing 5 ingestion config fields: per-source chunk limit, max sources, embedding rate limit, extraction model (dropdown), and extraction pool size. - New SettingsTab.tsx component with commit-on-blur number inputs and model dropdown using useAvailableModels() - Knowledge index.tsx gains 4th tab (list | graph | sources | settings) - Remove entire Knowledge Library section from Settings → Chat panel (auto-ingest toggles remain config-only for power users) - i18n: 18 new keys across 14 locales + en-XA pseudolocale - Remove obsolete ChatPanel.knowledgeAutoIngest test file - Remove dead Knowledge Library test block from SettingsChatPanelCoverage - Update deadKeys baseline (21 → 31) for removed ChatPanel keys Closes the frontend follow-up from PR #2468.
Add a dedicated Settings tab to the Knowledge page exposing 5 ingestion config fields: per-source chunk limit, max sources, embedding rate limit, extraction model (dropdown), and extraction pool size. - New SettingsTab.tsx component with commit-on-blur number inputs and model dropdown using useAvailableModels() - Knowledge index.tsx gains 4th tab (list | graph | sources | settings) - Remove entire Knowledge Library section from Settings → Chat panel (auto-ingest toggles remain config-only for power users) - i18n: 18 new keys across 14 locales + en-XA pseudolocale - Remove obsolete ChatPanel.knowledgeAutoIngest test file - Remove dead Knowledge Library test block from SettingsChatPanelCoverage - Update deadKeys baseline (21 → 31) for removed ChatPanel keys Closes the frontend follow-up from PR #2468.
Add a dedicated Settings tab to the Knowledge page exposing 5 ingestion config fields: per-source chunk limit, max sources, embedding rate limit, extraction model (dropdown), and extraction pool size. - New SettingsTab.tsx component with commit-on-blur number inputs and model dropdown using useAvailableModels() - Knowledge index.tsx gains 4th tab (list | graph | sources | settings) - Remove entire Knowledge Library section from Settings → Chat panel (auto-ingest toggles remain config-only for power users) - i18n: 18 new keys across 14 locales + en-XA pseudolocale - Remove obsolete ChatPanel.knowledgeAutoIngest test file - Remove dead Knowledge Library test block from SettingsChatPanelCoverage - Update deadKeys baseline (21 → 31) for removed ChatPanel keys Closes the frontend follow-up from PR #2468. Co-authored-by: zejiangg <zejiangg@amazon.com>
…ble extraction model (kirodotdev#2468) The per-source chunk budgets (auto_ingest_chunk_budget, folder_ingest_chunk_budget) bound cost per folder per sweep, but with many directories registered the total work per sweep = N × per-source budget -- causing LLM pool saturation, embedding backlogs, and gateway stalls (kirodotdev#2175, kirodotdev#2336, kirodotdev#2448). Add five new KnowledgeConfig fields: - sweep_chunk_budget (default 500): hard cap on total chunks across ALL sources in one watcher sweep. Once reached, remaining sources defer to next sweep. - max_sources (default 50): cap on registered source count. Auto-discovery paths stop registering once the cap is reached. - embed_rate_limit (default 120/min): token-bucket throttle on embedding generation, preventing CPU/memory saturation from parallel embed batches. - extraction_model (default empty = agent.model): extraction LLM is no longer hardcoded to claude-haiku-4.5; it uses the user's default model, overridable. - extraction_pool_size (default 3): configurable concurrent extraction workers. All five are live-reloaded (no restart needed except pool size) and exposed in the Settings PATCH schema. 0 = unbounded for all numeric fields. Implementation: - watcher._scan() tracks chunks_used across all folder sources, breaking when the global budget is exhausted - folder_watcher.scan_source() reports chunks_ingested in stats - store.create_auto_source_unless_dismissed() enforces max_sources atomically - EmbedRateLimiter token bucket in ingestion.py, called from _embed_item() - _install_knowledge_agent() reads extraction_model from config - LLMPool.start() reads extraction_pool_size from config - handlers/core.py allows PATCH for all 5 new keys Tests: 24 new tests covering config defaults, rate limiter, source cap, sweep budget, pool size config, and extraction model resolution. Co-authored-by: Joe Guo <zejiangg@amazon.com>
…tdev#3335) Add a dedicated Settings tab to the Knowledge page exposing 5 ingestion config fields: per-source chunk limit, max sources, embedding rate limit, extraction model (dropdown), and extraction pool size. - New SettingsTab.tsx component with commit-on-blur number inputs and model dropdown using useAvailableModels() - Knowledge index.tsx gains 4th tab (list | graph | sources | settings) - Remove entire Knowledge Library section from Settings → Chat panel (auto-ingest toggles remain config-only for power users) - i18n: 18 new keys across 14 locales + en-XA pseudolocale - Remove obsolete ChatPanel.knowledgeAutoIngest test file - Remove dead Knowledge Library test block from SettingsChatPanelCoverage - Update deadKeys baseline (21 → 31) for removed ChatPanel keys Closes the frontend follow-up from PR kirodotdev#2468. Co-authored-by: zejiangg <zejiangg@amazon.com>
Problem
Per-source chunk budgets (
auto_ingest_chunk_budget=150,folder_ingest_chunk_budget=300)bound cost per folder per sweep. When many directories are registered — via
auto_register_project_docson a multi-project workspace, or a user adding manyfolders — the total extraction work per sweep = N × per-source budget:
Each chunk costs one LLM extraction call on the worker pool. This burst saturates the
LLM pool (default 3 workers), generates a massive embedding backlog, starves
chat-session inference, and can stall/respawn-loop the gateway (#2175, #2336, #2448).
Additionally, the extraction model was hardcoded to
claude-haiku-4.5with no useroverride — users couldn't choose their own model for knowledge extraction.
Why it matters
A user who adds a few project folders or opens a multi-project workspace silently
triggers thousands of billed extraction calls per 5-minute sweep with no global cap.
The existing per-source budgets are necessary but insufficient — they're additive
across sources with no ceiling.
Fix (symptoms → root cause → change)
Symptom: gateway stalls under heavy knowledge ingestion load.
Root cause: no global cap on total extraction work per sweep; extraction model not
configurable; no embedding rate limit; no source count cap.
Change: five new
KnowledgeConfigfields that bound the overall cost envelope:sweep_chunk_budgetmax_sourcesembed_rate_limitextraction_modelagent.model)extraction_pool_sizeCost consequence of the model default change: extraction previously used hardcoded
claude-haiku-4.5. Now it inheritsagent.model— a user chatting on an Opus-classmodel will pay chat-model rates per extraction chunk unless they explicitly set
extraction_model: claude-haiku-4.5. Thesweep_chunk_budget(500, down fromunbounded) bounds total cost regardless of model choice.
All numeric fields: 0 = unbounded (preserves old behavior for power users).
sweep_chunk_budget,max_sources, andembed_rate_limitare live-reloaded (takeeffect on the next watcher sweep, no restart).
extraction_modelandextraction_pool_sizerequire a gateway restart.Tests
test/test_knowledge_budget.py— 24 new tests:TestKnowledgeConfigBudgetDefaults(7): all fields have correct defaults, zero-is-unboundedTestEmbedRateLimiter(4): zero-rate noop, high-rate no-block, setter reset, config integrationTestMaxSourcesCap(4): under-cap allows, at-cap blocks, zero unbounded, existing URI ignores capTestSweepChunkBudget(2): reads from config, zero means unboundedTestPoolSizeConfig(4): default, configured, clamped max, clamped minTestExtractionModelResolution(2): empty uses agent.model, explicit overridesPre-existing tests fixed to work with new behavior:
test_knowledge_folder_cost_guards.py: mock setssweep_chunk_budget=0(unbounded)test_knowledge_project_docs.py:max_sourceshandled via safeint()conversiontest_llm_pool.py: pool size only overridden when config explicitly sets the keyManual verification
N/A — backend infrastructure, no UI surface in this PR. All five config knobs are
accessible via
kirocrew config set knowledge.<key> <value>and the Settings PATCHAPI (
/api/configwithknowledge.sweep_chunk_budget, etc.).Screenshots
N/A — no user-visible UI change in this PR. Frontend Settings UI card is a follow-up
PR (requires i18n key additions across 12 locales + screenshot capture).
Follow-up (not included)
ChatPanel.tsxadditions with i18n for the 5 new fieldsextraction_modellive-reload (rebuild agent config + recycle workers on PATCH)max_sourcesenforcement on the manualPOST /api/knowledge/sourcesendpoint