mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-31 16:49:34 +00:00
fix(engine): eagerly initialize engine v2 at startup
The gateway API endpoints (/api/engine/missions, etc.) call bridge query functions that return empty results when the engine state hasn't been initialized yet. Previously, initialization only happened lazily on the first chat message via handle_with_engine(). Now when ENGINE_V2=true, the engine is initialized in Agent::run() before channels start, so the self-improvement mission and other engine state is available to gateway API endpoints immediately. Also rename get_or_init_engine → init_engine and make it public so it can be called from agent_loop.rs at startup. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This commit is contained in:
@@ -450,6 +450,14 @@ impl Agent {
|
||||
None
|
||||
};
|
||||
|
||||
// Eagerly initialize engine v2 so gateway API endpoints can serve
|
||||
// data (projects, missions, threads) before the first chat message.
|
||||
if crate::bridge::is_engine_v2_enabled()
|
||||
&& let Err(e) = crate::bridge::init_engine(&self).await
|
||||
{
|
||||
tracing::debug!("engine v2: eager init failed: {e}");
|
||||
}
|
||||
|
||||
// Start channels
|
||||
let mut message_stream = self.channels.start_all().await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user