micro-models-agent 0.13.2 → 0.13.3
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/core/agent.js +11 -2
- package/package.json +1 -1
package/dist/core/agent.js
CHANGED
|
@@ -137,6 +137,7 @@ export class Agent {
|
|
|
137
137
|
const toolCalls = [];
|
|
138
138
|
let sawToolCall = false;
|
|
139
139
|
let emittedReasoning = false;
|
|
140
|
+
const textChunks = [];
|
|
140
141
|
this.emitPhase(iteration, "thinking", onPhase);
|
|
141
142
|
try {
|
|
142
143
|
for await (const chunk of llmProvider.chat(history, allTools)) {
|
|
@@ -145,8 +146,7 @@ export class Agent {
|
|
|
145
146
|
onMeta?.("\n\n");
|
|
146
147
|
}
|
|
147
148
|
textContent += chunk.content;
|
|
148
|
-
|
|
149
|
-
onChunk?.(textOut);
|
|
149
|
+
textChunks.push(chunk.content);
|
|
150
150
|
}
|
|
151
151
|
if (chunk.type === "reasoning" && chunk.content) {
|
|
152
152
|
reasoningContent += chunk.content;
|
|
@@ -189,6 +189,15 @@ export class Agent {
|
|
|
189
189
|
finally {
|
|
190
190
|
this.emitPhase(iteration, "done", onPhase);
|
|
191
191
|
}
|
|
192
|
+
// Display buffered text only if no tool call in this response.
|
|
193
|
+
// When a tool call is present, text is just the model describing
|
|
194
|
+
// its tool call (e.g. raw JSON args) — suppress it.
|
|
195
|
+
if (!sawToolCall && textChunks.length > 0) {
|
|
196
|
+
for (const chunk of textChunks) {
|
|
197
|
+
const textOut = pluginManager.runOnText({ iteration, logger }, chunk);
|
|
198
|
+
onChunk?.(textOut);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
192
201
|
let llmResponse = null;
|
|
193
202
|
if (sawToolCall) {
|
|
194
203
|
llmResponse = { type: "tool_call", calls: toolCalls };
|