@agentionai/agents 1.9.0 → 1.10.0
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.
|
@@ -99,6 +99,18 @@ export declare class LlamaCppAgent extends OpenAICompatibleAgent {
|
|
|
99
99
|
* included, is on `raw`.
|
|
100
100
|
*/
|
|
101
101
|
listModels(): Promise<ModelInfo<LlamaCppModelCard>[]>;
|
|
102
|
+
/**
|
|
103
|
+
* Tells the server to end the model's reasoning phase early, mid-stream,
|
|
104
|
+
* via llama.cpp's proprietary `/chat/completions/control` endpoint. Useful
|
|
105
|
+
* for cutting off a model that is thinking for too long without waiting
|
|
106
|
+
* for it to decide to stop on its own.
|
|
107
|
+
*
|
|
108
|
+
* A no-op if no streamed completion is in flight yet (`lastChunkId` unset).
|
|
109
|
+
* Best-effort: a failed request is logged (when `debug` is on) rather than
|
|
110
|
+
* thrown, since this is a side channel to a turn that should otherwise
|
|
111
|
+
* proceed normally.
|
|
112
|
+
*/
|
|
113
|
+
skipReasoning(): Promise<void>;
|
|
102
114
|
}
|
|
103
115
|
export {};
|
|
104
116
|
//# sourceMappingURL=LlamaCppAgent.d.ts.map
|
|
@@ -68,6 +68,36 @@ class LlamaCppAgent extends OpenAICompatibleAgent_1.OpenAICompatibleAgent {
|
|
|
68
68
|
},
|
|
69
69
|
}));
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Tells the server to end the model's reasoning phase early, mid-stream,
|
|
73
|
+
* via llama.cpp's proprietary `/chat/completions/control` endpoint. Useful
|
|
74
|
+
* for cutting off a model that is thinking for too long without waiting
|
|
75
|
+
* for it to decide to stop on its own.
|
|
76
|
+
*
|
|
77
|
+
* A no-op if no streamed completion is in flight yet (`lastChunkId` unset).
|
|
78
|
+
* Best-effort: a failed request is logged (when `debug` is on) rather than
|
|
79
|
+
* thrown, since this is a side channel to a turn that should otherwise
|
|
80
|
+
* proceed normally.
|
|
81
|
+
*/
|
|
82
|
+
async skipReasoning() {
|
|
83
|
+
if (!this.lastChunkId)
|
|
84
|
+
return;
|
|
85
|
+
try {
|
|
86
|
+
await fetch(`${this.config.baseURL}/chat/completions/control`, {
|
|
87
|
+
method: "POST",
|
|
88
|
+
headers: { "Content-Type": "application/json" },
|
|
89
|
+
body: JSON.stringify({
|
|
90
|
+
action: "reasoning_end",
|
|
91
|
+
id: this.lastChunkId,
|
|
92
|
+
}),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
if (this.debug) {
|
|
97
|
+
console.error(`Failed to signal reasoning_end to ${this.getVendorName()}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
71
101
|
}
|
|
72
102
|
exports.LlamaCppAgent = LlamaCppAgent;
|
|
73
103
|
//# sourceMappingURL=LlamaCppAgent.js.map
|
|
@@ -35,6 +35,14 @@ export declare abstract class OpenAICompatibleAgent extends BaseAgent {
|
|
|
35
35
|
protected config: Partial<OpenAICompatibleConfig>;
|
|
36
36
|
private vizEventId?;
|
|
37
37
|
private currentToolCallCount;
|
|
38
|
+
/**
|
|
39
|
+
* The `id` of the most recently seen streamed `ChatCompletionChunk`
|
|
40
|
+
* (`chatcmpl-...`). Internal only — some servers key control-plane calls
|
|
41
|
+
* (e.g. llama.cpp's `/chat/completions/control`) off the in-flight
|
|
42
|
+
* completion's id, so it needs to be captured somewhere subclasses can
|
|
43
|
+
* reach it, but it isn't part of the public `StreamChunk` shape.
|
|
44
|
+
*/
|
|
45
|
+
protected lastChunkId?: string;
|
|
38
46
|
/**
|
|
39
47
|
* Whether this server accepts a replayed `reasoning_content` field on an
|
|
40
48
|
* assistant message. `undefined` until proven otherwise — see
|
|
@@ -401,6 +401,8 @@ class OpenAICompatibleAgent extends BaseAgent_1.BaseAgent {
|
|
|
401
401
|
// taking the last one covers both layouts without double-counting.
|
|
402
402
|
if (chunk.usage)
|
|
403
403
|
streamUsage = chunk.usage;
|
|
404
|
+
if (chunk.id)
|
|
405
|
+
this.lastChunkId = chunk.id;
|
|
404
406
|
if (chunk.choices.length === 0)
|
|
405
407
|
continue;
|
|
406
408
|
const choice = chunk.choices[0];
|