lfnovo/open-notebook · warning · HTTPException
Answer model {ask_request.answer_model} not found
Error message
Answer model {ask_request.answer_model} not found What it means
400 from /api/search/ask when the answer model ID does not exist in the database. The answer model generates intermediate answers in the multi-step ask pipeline.
Source
Thrown at api/routers/search.py:138
yield f"data: {json.dumps(error_data)}\n\n"
@router.post("/search/ask")
async def ask_knowledge_base(ask_request: AskRequest):
"""Ask the knowledge base a question using AI models."""
try:
# Validate models exist
strategy_model = await Model.get(ask_request.strategy_model)
answer_model = await Model.get(ask_request.answer_model)
final_answer_model = await Model.get(ask_request.final_answer_model)
if not strategy_model:
raise HTTPException(
status_code=400,
detail=f"Strategy model {ask_request.strategy_model} not found",
)
if not answer_model:
raise HTTPException(
status_code=400,
detail=f"Answer model {ask_request.answer_model} not found",
)
if not final_answer_model:
raise HTTPException(
status_code=400,
detail=f"Final answer model {ask_request.final_answer_model} not found",
)
# Check if embedding model is available
if not await model_manager.get_embedding_model():
raise HTTPException(
status_code=400,
detail="Ask feature requires an embedding model. Please configure one in the Models section.",
)
# For streaming response
return StreamingResponse(View on GitHub (pinned to a7de90d38a)
Solutions
- List models via GET /api/models and pick a valid answer_model ID
- Reset default model selections in settings
Defensive patterns
Strategy: validation
Validate before calling
const valid = models.some(m => m.id === req.answer_model);
if (!valid) req.answer_model = getDefault('answer'); Type guard
const isKnownModelId = (id: string, models: Model[]) => models.some(m => m.id === id);
Try / catch
catch (e) { if (e.status === 400 && e.detail.includes('Answer model')) refreshModelSelection(); } Prevention
- Validate all three model IDs before submitting ask requests
When it happens
Trigger: POST /api/search/ask with an answer_model ID absent from the models table.
Common situations: Same as other model lookups: deleted model, stale client state, mismatched environment.
Related errors
- Strategy model {ask_request.strategy_model} not found
- Final answer model {ask_request.final_answer_model} not foun
- Ask feature requires an embedding model. Please configure on
- No embedding model configured. Please configure one in the M
- Item type must be either 'source' or 'note'
AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27).
Data as JSON: /api/errors/2bcc333c4aaf6b4e.
Report an issue: GitHub.