mirror of
https://github.com/open-jarvis/OpenJarvis.git
synced 2026-07-31 03:12:16 +00:00
fix: use fresh engine for agent ticks, not wrapped server engine
The server's engine is wrapped in MultiEngine → InstrumentedEngine → GuardrailsEngine. When reused from a background thread for agent ticks, this chain returns empty content. Create a fresh OllamaEngine for each tick instead, which reliably returns model output. Also fixes Run Now endpoint to use the same lightweight system approach. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
808ec6eb5c
commit
8b358620da
@@ -78,7 +78,25 @@ class _LightweightSystem:
|
||||
def _make_lightweight_system(
|
||||
engine: Any, model: str, config: Any = None,
|
||||
) -> _LightweightSystem:
|
||||
"""Build a minimal system from the server's existing state."""
|
||||
"""Build a minimal system using a plain engine for the given model.
|
||||
|
||||
The server's ``app.state.engine`` is heavily wrapped
|
||||
(MultiEngine → InstrumentedEngine → GuardrailsEngine) and can
|
||||
hang when reused from a background thread. Instead, create a
|
||||
fresh OllamaEngine pointed at the same backend.
|
||||
"""
|
||||
try:
|
||||
from openjarvis.core.config import load_config
|
||||
from openjarvis.engine._discovery import get_engine
|
||||
|
||||
cfg = config if config is not None else load_config()
|
||||
resolved = get_engine(cfg)
|
||||
if resolved is not None:
|
||||
_, plain_engine = resolved
|
||||
return _LightweightSystem(plain_engine, model, cfg)
|
||||
except Exception:
|
||||
pass
|
||||
# Fallback to the (wrapped) server engine
|
||||
return _LightweightSystem(engine, model, config)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user