Fosowl/agenticSeek · error · Exception
Model not set
Error message
Model not set
What it means
Generator.start() refuses to begin generation when no model has been configured on the generator instance. The library requires an explicit call to set_model() before start() so it knows which LLM to query; without it, generation state would be meaningless. It is thrown as a plain Exception before any thread is spawned or lock is taken.
Source
Thrown at llm_server/sources/generator.py:41
def __init__(self):
self.model = None
self.state = GenerationState()
self.logger = logging.getLogger(__name__)
handler = logging.StreamHandler()
handler.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
self.logger.addHandler(handler)
self.logger.setLevel(logging.INFO)
cache = Cache()
def set_model(self, model: str) -> None:
self.logger.info(f"Model set to {model}")
self.model = model
def start(self, history: list) -> bool:
if self.model is None:
raise Exception("Model not set")
with self.state.lock:
if self.state.is_generating:
return False
self.state.is_generating = True
self.logger.info("Starting generation")
threading.Thread(target=self.generate, args=(history,)).start()
return True
def get_status(self) -> dict:
with self.state.lock:
return self.state.status()
@abstractmethod
def generate(self, history: list) -> None:
"""
Generate text using the model.
args:
history: list of stringsView on GitHub (pinned to ae57a23577)
Solutions
- Call generator.set_model("<model-name>") with a valid model name before calling start(history).
- Verify the config-loading path actually invokes set_model on the same generator instance used for start().
- Guard the call site: check generator.model is not None (or wrap set_model+start in an init routine) before triggering any generation.
- Log/inspect the generator instance to confirm you are not using a second, unconfigured instance.
Example fix
// before
generator = Generator(state)
generator.start(history) # Exception: Model not set
// after
generator = Generator(state)
generator.set_model("llama3")
generator.start(history) Defensive patterns
Strategy: validation
Validate before calling
def ensure_model_ready(generator):
if getattr(generator, "model", None) is None:
raise RuntimeError("Call generator.set_model(...) before start()")
return generator
# usage
ensure_model_ready(generator).start(history) Type guard
def is_model_set(generator) -> bool:
return getattr(generator, "model", None) is not None Try / catch
try:
ok = generator.start(history)
except Exception as e:
if "Model not set" in str(e):
generator.set_model(config["model"])
ok = generator.start(history)
else:
raise Prevention
- Always call set_model() immediately after constructing the generator, ideally in a shared init function.
- Centralize generator construction so every caller receives a configured instance.
- Add a startup assertion: assert generator.model is not None before accepting user input.
- Load and validate the model name from config at app boot, failing fast if missing.
When it happens
Trigger: Calling start(history) (directly or via start_generation, speak_answer, start_listening, or animate_thinking) when self.model is None — i.e. set_model(model) was never called on the generator instance.
Common situations: Fresh install where the model name was never configured; config file loaded but the set_model call skipped or run on a different generator instance; model name key missing/renamed in user config; instantiating a second Generator and forgetting to re-set the model.
Related errors
- Unknown provider: {provider_name}
- Prompt file not found at path: {file_path}
- Permission denied to read prompt file at path: {file_path}
- API key {api_key_var} not found in .env file. Please add it
- Ollama connection failed. is the server running ?
AI-assisted analysis of Fosowl/agenticSeek@ae57a23577 (2026-08-30).
Data as JSON: /api/errors/54d5d7997e7936e2.
Report an issue: GitHub.