lfnovo/open-notebook · warning · HTTPException

Final answer model {ask_request.final_answer_model} not foun

Error message

Final answer model {ask_request.final_answer_model} not found

What it means

400 from /api/search/ask when the final answer model ID does not exist in the database. This model produces the final polished answer of the ask pipeline.

Source

Thrown at api/routers/search.py:143

    """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(
            stream_ask_response(
                ask_request.question, strategy_model, answer_model, final_answer_model
            ),
            media_type="text/event-stream",
            headers={

View on GitHub (pinned to a7de90d38a)

Solutions

  1. Validate all three model IDs against GET /api/models before asking
  2. Re-select models in the UI so fresh IDs are sent
Defensive patterns

Strategy: validation

Validate before calling

const valid = models.some(m => m.id === req.final_answer_model);
if (!valid) req.final_answer_model = getDefault('final_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('Final answer model')) refreshModelSelection(); }

Prevention

When it happens

Trigger: POST /api/search/ask with a final_answer_model ID that has no corresponding models row.

Common situations: Deleted or renamed models, stale persisted request payloads from the UI.

Related errors


AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27). Data as JSON: /api/errors/9b697f7d3abf0d39. Report an issue: GitHub.