MCPcopy Create free account
hub / github.com/diillson/chatcli / TestMoaTurn_NativeKnowledgeLoop

Function TestMoaTurn_NativeKnowledgeLoop

cli/moa_turn_test.go:299–323  ·  view source on GitHub ↗

A MoA participant must be able to ground its answer in the attached knowledge bases, exactly like a chat turn: the fake asks for a search on round one and only answers once the passages are folded back in.

(t *testing.T)

Source from the content-addressed store, hash-verified

297// knowledge bases, exactly like a chat turn: the fake asks for a search on
298// round one and only answers once the passages are folded back in.
299func TestMoaTurn_NativeKnowledgeLoop(t *testing.T) {
300 t.Setenv(chatKnowledgeEnvVar, "true")
301 cli := newKnowledgeTestCLI(t)
302 plugins.SetKnowledgeAdapter(&knowledgePluginAdapter{cli: cli})
303 t.Cleanup(func() { plugins.SetKnowledgeAdapter(nil) })
304
305 fc := &knowledgeToolFake{}
306 cli.Provider, cli.Model, cli.Client = "fake", "m", fc
307
308 ts := cli.moaToolsetForRun(nil)
309 if !ts.knowledge {
310 t.Fatal("an attached knowledge base must grant the knowledge tool")
311 }
312 turn := cli.moaTurn(ts)
313 out, err := turn(context.Background(), moa.Ref{Provider: "fake", Model: "m"}, "como instalo?", nil)
314 if err != nil {
315 t.Fatal(err)
316 }
317 if out != "final grounded answer" {
318 t.Fatalf("out = %q", out)
319 }
320 if fc.calls != 2 {
321 t.Fatalf("expected decision + follow-up calls, got %d", fc.calls)
322 }
323}
324
325// moaRecallXMLFake drives the XML transport: the instruction must be pinned,
326// the call is answered with the full marker form, then prose.

Callers

nothing calls this directly

Calls 5

SetKnowledgeAdapterFunction · 0.92
newKnowledgeTestCLIFunction · 0.85
moaToolsetForRunMethod · 0.80
moaTurnMethod · 0.80
CleanupMethod · 0.45

Tested by

no test coverage detected