diff --git a/internal/agent/engines/llamacpp.go b/internal/agent/engines/llamacpp.go index 489c0c5..1f411e8 100644 --- a/internal/agent/engines/llamacpp.go +++ b/internal/agent/engines/llamacpp.go @@ -79,14 +79,15 @@ func (l *LlamaCpp) Commands(s ShardSpec) ([]Command, error) { // measure is one it has to route to blind. "--metrics", } - // The model's own chat template, which is what turns a tool call into a - // tool_calls array instead of a JSON object sitting in the reply text. + // The model's own chat template rather than a generic one, which is what + // renders tool definitions in the form the model was trained to read. // - // Without it qwen2.5-coder emitted exactly the right call — - // {"name": "list_files", "arguments": {"path": "."}} — as plain content, - // and every OpenAI-compatible client saw a model that ignores its tools. - // It also affects ordinary chat, because the generic fallback template is - // not the one the model was trained on. + // Pinned rather than relied on: build 10991 has it on by default, older + // builds do not, and an engine upgrade should not be able to change how + // prompts are built underneath a running fleet. Passing it explicitly was + // a no-op on the build here — it was added while chasing tool calls that + // came back as text, and did not fix that, which turned out to be the + // model rather than the template. if !hasFlag(p.Args, "--jinja", "--no-jinja") { args = append(args, "--jinja") } diff --git a/internal/agent/engines/llamacpp_test.go b/internal/agent/engines/llamacpp_test.go index c23deaf..30419ee 100644 --- a/internal/agent/engines/llamacpp_test.go +++ b/internal/agent/engines/llamacpp_test.go @@ -156,11 +156,12 @@ func flagValue(args []string, flag string) (string, bool) { } func TestLlamaCppUsesTheModelsChatTemplate(t *testing.T) { - // Tool calling is the reason. Without --jinja, llama.cpp uses a generic - // template and a model that decides to call a tool emits the call as text: - // qwen2.5-coder returned {"name": "list_files", "arguments": {"path": "."}} - // in content, with tool_calls null, so every OpenAI-compatible client saw a - // model that ignores the tools it was given. + // Pinned so an engine upgrade cannot change how prompts are built under a + // running fleet: build 10991 defaults to jinja, older builds do not. + // + // Not a fix for tool calling, though it was added while chasing that. On + // this build the flag is a no-op and the behaviour is identical with and + // without it. l := &LlamaCpp{} cmds, err := l.Commands(ShardSpec{HTTPPort: 8080, Profile: Profile{ModelPath: "/m.gguf"}}) if err != nil {