mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-11-27 07:40:05 +00:00
* ui: add @ggml-org/llama-harness, the agentic loop as a package, in ui/lib/harness
Llama Harness is the agentic loop as headless TypeScript with no UI, no DOM and no dependencies. It streams a turn, runs
the tools the model called, gives it the results, and repeats until the model answers without a tool call. An app gives
it an inference client and tools, and reads the run as a stream of events: run(messages, tools, signal). It ships a
client for any OpenAI-compatible endpoint, so it also runs on its own in Node. The UI workflow type-checks, tests and
packs it.
Assisted-by: Claude (Fable 5.2)
* ui: run Llama Chat's agentic loop through @ggml-org/llama-harness
The loop leaves the agentic store, which now gives the harness what the app owns: ChatService as its inference client,
the enabled tools behind the permission gate, and the callbacks that store each turn. Its API and the flow's callbacks
are unchanged. A unit test runs the flow end to end with the server and the tools mocked.
Chat compiles the harness from source through an alias, so the builds that copy or isolate ui/apps/chat now bring
ui/lib/harness along: CMake and Nix through LLAMA_HARNESS_DIR, the Dockerfiles with a COPY.
Assisted-by: Claude (Fable 5.2)
* ui: bring the architecture docs in line with the ui/ folder
The layout card no longer calls the move planned, the harness is in the
pages, and they say that Llama Chat does not import @ggml-org/llama-ui yet.
Assisted-by: Claude (Opus 5.5 Medium)
* ui: phrase agent traces in @ggml-org/llama-harness
The plain-language lines of an agent trace move out of Llama Chat into the
harness, as a headless trace module any app on it can use: what one tool call
did ("Read app.ts"), what it is doing now ("Running npm test", "Thinking"),
what a run of calls did ("Ran 3 commands, read 2 files"), and how calls fold
into one row with the reasoning around them.
createTracePhraser knows llama-server's built-in tools. An app adds its own
with resolvers and a phrasing table; any other tool reads as "Used <tool>"
with its main argument, and a call with a description shows the model's own
words. The lenient parse of streamed arguments and the targeted read of a
path in a whole-file argument move with it.
Llama Chat keeps its Svelte components and phrases only its own tools: the
browser tools, web search and tool_search. Its functions keep their names and
signatures, so nothing that renders a trace changes.
Assisted-by: Claude (Opus 5.5 Medium)
42 lines
994 B
TypeScript
42 lines
994 B
TypeScript
import { createAsyncQueue } from '#lib/utils/async-queue.ts';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
async function collect<T>(queue: AsyncIterable<T>): Promise<T[]> {
|
|
const items: T[] = [];
|
|
|
|
for await (const item of queue) items.push(item);
|
|
|
|
return items;
|
|
}
|
|
|
|
describe('createAsyncQueue', () => {
|
|
it('yields the items pushed before and during the iteration, then ends on close', async () => {
|
|
const queue = createAsyncQueue<number>();
|
|
|
|
queue.push(1);
|
|
|
|
const collected = collect(queue);
|
|
|
|
await Promise.resolve();
|
|
queue.push(2);
|
|
queue.push(3);
|
|
queue.close();
|
|
|
|
expect(await collected).toEqual([1, 2, 3]);
|
|
});
|
|
|
|
it('throws the failure after the pushed items are read', async () => {
|
|
const queue = createAsyncQueue<number>();
|
|
const seen: number[] = [];
|
|
|
|
queue.push(1);
|
|
queue.fail(new Error('cut'));
|
|
|
|
await expect(
|
|
(async () => {
|
|
for await (const item of queue) seen.push(item);
|
|
})()
|
|
).rejects.toThrow('cut');
|
|
expect(seen).toEqual([1]);
|
|
});
|
|
});
|