mirror of
https://github.com/open-jarvis/OpenJarvis.git
synced 2026-07-28 05:12:26 +00:00
`_stream_managed_agent` had diverged from the canonical cli/ask.py path and lost three behaviours. All three are fixed via small extracted, unit-tested helpers: - #382: cross-request history replay dropped stored `tool_calls`, so the model never saw its own prior tool use and fabricated tool output on turn 2+. `_replay_history_messages` now reconstructs the assistant tool-use message plus matching tool-result messages (synthesised, consistent tool_call_ids). - #386: only temperature/max_tokens reached the engine. `_sampler_kwargs` forwards repetition_penalty / top_p / top_k / min_p / frequency_penalty / presence_penalty when set in the agent config (opt-in; default agents send nothing extra). Fixes degenerate repetition loops on local models with no repetition_penalty. - #395: tools were built with a bare `tool_cls()`, so memory_* / channel_* / llm tools loaded with no backend and failed on every call. `_instantiate_managed_tool` injects backend / channel / engine the same way cli/ask.py::_build_tools does. Verified empirically: replay emits user → assistant(tool_calls) → tool(result) with matching ids; sampler extraction forwards only set keys; DI gives memory tools a backend and llm the engine/model. New tests in tests/server/test_managed_agent_streaming.py (helpers are pure, so verifiable without a live engine). 38 passed locally incl. existing route tests. Closes #382 Closes #386 Closes #395 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>