@0perator/operator 0.1.276 → 0.1.277
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine/agent.js +1 -1
- package/dist/engine/aurora.js +26 -9
- package/package.json +1 -1
package/dist/engine/agent.js
CHANGED
|
@@ -658,7 +658,7 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
658
658
|
const mKey = endpointKey(endpoint.base, endpoint.model);
|
|
659
659
|
if (response.promptTokens && response.promptTokens > 0) {
|
|
660
660
|
globalTokenMeter.observePrompt(mKey, requestChars(messages, opts.toolSchemas), response.promptTokens);
|
|
661
|
-
opts.onCacheStats?.({ promptTokens: response.promptTokens, cached: response.cacheN
|
|
661
|
+
opts.onCacheStats?.({ promptTokens: response.promptTokens, cached: response.cacheN, promptMs: response.promptMs });
|
|
662
662
|
}
|
|
663
663
|
if (response.tokensExact && response.tokens && response.tokens > 0) {
|
|
664
664
|
const outChars = (response.content?.length ?? 0) + (response.reasoningContent?.length ?? 0)
|
package/dist/engine/aurora.js
CHANGED
|
@@ -192,11 +192,22 @@ export function trimLoop(text) {
|
|
|
192
192
|
}
|
|
193
193
|
return out.join("\n").trim();
|
|
194
194
|
}
|
|
195
|
+
/** Pure decision: do llama.cpp cache/speculation knobs ship to this endpoint? YES for the llama
|
|
196
|
+
* dialect (fleet/local) and for OUR OWN vendor gateway (*.axe.onl — OpenAI on the wire, llama.cpp
|
|
197
|
+
* at the end of it). NO for third-party openai-dialect BYO (strict fields only — unknown keys may 400).
|
|
198
|
+
* Exported so the scope is pinned by unit tests without needing a resolvable axe.onl echo server. */
|
|
199
|
+
export function shipsLlamaCacheKnobs(base, transport) {
|
|
200
|
+
return transport !== "openai" || requiresOperatorToken(base);
|
|
201
|
+
}
|
|
195
202
|
function requestBody(messages, o, stream) {
|
|
196
|
-
// Transport dialect: llama.cpp-only fields ship
|
|
197
|
-
//
|
|
198
|
-
//
|
|
203
|
+
// Transport dialect: llama.cpp-only fields ship to Aurora/fleet (default "llama") AND to our OWN
|
|
204
|
+
// vendor gateway (*.axe.onl — LiteLLM terminating at our llama.cpp, so the wire is OpenAI but the
|
|
205
|
+
// BACKEND understands the knobs; measured live 2026-10-11: extras pass api.axe.onl with no 400 and
|
|
206
|
+
// no fallback trip). A genuine third-party "openai" BYO (qwencloudapi.com, …) still gets standard
|
|
207
|
+
// fields only — third-party gateways can 400 on unknown keys, and silence on extras is not a
|
|
208
|
+
// contract we should bank on.
|
|
199
209
|
const llama = o.transport !== "openai";
|
|
210
|
+
const cacheKnobs = shipsLlamaCacheKnobs(o.base, o.transport); // KV-reuse + speculation-off: llama.cpp semantics, ours to send
|
|
200
211
|
return JSON.stringify({
|
|
201
212
|
model: o.model, messages, stream,
|
|
202
213
|
// Ask the server for an exact usage report on the final SSE chunk. Without this, llama.cpp omits
|
|
@@ -209,16 +220,16 @@ function requestBody(messages, o, stream) {
|
|
|
209
220
|
// (system + tools + history) every round, and cache-safe compaction re-sends the evicted span as an exact
|
|
210
221
|
// PREFIX of the last live request. Without cache_prompt the single-slot server RE-PREFILLS that whole
|
|
211
222
|
// prefix each time — the "compaction takes 4-5 min at 80k ctx" and "long sessions crawl" symptom. With it,
|
|
212
|
-
// the server prefix-matches and prefills only the new tail. llama dialect
|
|
213
|
-
...(
|
|
223
|
+
// the server prefix-matches and prefills only the new tail. llama dialect (and our own gateway).
|
|
224
|
+
...(cacheKnobs ? { cache_prompt: true } : {}),
|
|
214
225
|
// GW-26 — ngram speculation is DEFAULT-ON in modern llama.cpp and a NET LOSS on the DeltaNet-hybrid
|
|
215
226
|
// Aurora at untuned draft params: measured live on :8097 (b11146, ctx 307K), acceptance 3-17% and
|
|
216
227
|
// 4-6 tok/s decode WITH it vs 20-25 tok/s WITHOUT — every rejected draft forces a multi-token
|
|
217
228
|
// re-verify + recache on the hybrid. Shape verified live: {"speculative":{"ngram":{"enabled":false}}}
|
|
218
229
|
// -> timings.draft_n drops to 0 and decode jumps 4x; a `{"type":"none"}` variant is silently IGNORED,
|
|
219
|
-
// so keep this exact shape. llama dialect
|
|
220
|
-
// lands: enableSpeculation: true.
|
|
221
|
-
...(
|
|
230
|
+
// so keep this exact shape. llama dialect (and our own gateway). Escape hatch when a retuned/
|
|
231
|
+
// high-acceptance bless lands: enableSpeculation: true.
|
|
232
|
+
...(cacheKnobs && !o.enableSpeculation ? { speculative: { ngram: { enabled: false } } } : {}),
|
|
222
233
|
max_tokens: o.maxTokens ?? 8192, temperature: o.temperature ?? 0.7,
|
|
223
234
|
...(o.tools?.length ? { tools: o.tools, tool_choice: "auto", parallel_tool_calls: true } : {}),
|
|
224
235
|
// /think: re-enable the model's native reasoning for THIS request, overriding the server's
|
|
@@ -479,7 +490,13 @@ export async function chat(messages, o) {
|
|
|
479
490
|
* (when present) prices the bust in wall-seconds — the number that makes "why is it crawling" answerable. */
|
|
480
491
|
export function cacheBustNotice(o) {
|
|
481
492
|
const min = o.minTokens ?? 8000;
|
|
482
|
-
|
|
493
|
+
// Only name a bust when the SERVER MEASURED zero reuse. `cached === undefined` means the server
|
|
494
|
+
// reported no cache telemetry at all (a gateway that strips llama.cpp `timings` and does not return
|
|
495
|
+
// prompt_tokens_details — measured live on api.axe.onl, 2026-10-11: every continuation looked like a
|
|
496
|
+
// 0-cached bust while the backend was in fact serving warm (38.5s cold vs 4.5s same-prompt)). An
|
|
497
|
+
// unknown must never be fabricated into a measurement — the false alarm made a healthy session look
|
|
498
|
+
// like it was re-prefilling 254K tokens.
|
|
499
|
+
if (o.requestIndex <= 1 || o.promptTokens < min || o.cached !== 0)
|
|
483
500
|
return null;
|
|
484
501
|
const secs = o.promptMs ? ` (~${(o.promptMs / 1000).toFixed(1)}s prefill)` : "";
|
|
485
502
|
return `prefix cache missed on a continuation — ${o.promptTokens.toLocaleString()} tokens re-prefilled${secs}`;
|