@womp/spark-agent 13.0.0 → 13.0.1
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/CHANGELOG.md +10 -0
- package/dist/agent.js +21 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,16 @@ Notable changes to `@womp/spark-agent`, newest first. Versions follow
|
|
|
4
4
|
[Semantic Versioning](https://semver.org/). Add an entry with each version bump; describe what
|
|
5
5
|
changed for hosts and users, and how to migrate across breaking changes.
|
|
6
6
|
|
|
7
|
+
## 13.0.1 — 2026-10-20
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- A run is no longer failed by a tool call the model got wrong: input that does not parse or fails
|
|
12
|
+
the tool's schema, or a tool that does not exist. The AI SDK already answers such a call with a
|
|
13
|
+
tool error and lets the model continue. The run used to keep going, finish its work, and then be
|
|
14
|
+
stored `failed` with `AI_InvalidToolInputError: Invalid input for tool …` as its error (SW-006).
|
|
15
|
+
A tool that throws while it runs (a persistence barrier, say) still fails the run.
|
|
16
|
+
|
|
7
17
|
## 13.0.0 — 2026-10-19
|
|
8
18
|
|
|
9
19
|
A goal has no tries or credit limit of its own: it goes on until its conditions are verified, it is
|
package/dist/agent.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sparkErrorDiagnostics } from "./error-diagnostics.js";
|
|
2
|
-
import { createUIMessageStream, stepCountIs, streamText, } from "ai";
|
|
2
|
+
import { createUIMessageStream, InvalidToolInputError, NoSuchToolError, stepCountIs, streamText, ToolCallRepairError, } from "ai";
|
|
3
3
|
import { createSparkTools } from "./agent-tools.js";
|
|
4
4
|
import { sparkSystemPrompt } from "./prompt.js";
|
|
5
5
|
import { calculateStepCost } from "./pricing.js";
|
|
@@ -9,6 +9,16 @@ import { convertSparkMessages } from "./model-history.js";
|
|
|
9
9
|
function errorMessage(error) {
|
|
10
10
|
return sparkErrorDiagnostics(error).message;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* A tool call the model got wrong: input that does not parse or fails the
|
|
14
|
+
* tool's schema, or a tool that does not exist. The AI SDK answers it with a
|
|
15
|
+
* tool error and gives the model its next step, so it is not the run's failure.
|
|
16
|
+
*/
|
|
17
|
+
function isModelToolCallError(error) {
|
|
18
|
+
return (InvalidToolInputError.isInstance(error) ||
|
|
19
|
+
NoSuchToolError.isInstance(error) ||
|
|
20
|
+
ToolCallRepairError.isInstance(error));
|
|
21
|
+
}
|
|
12
22
|
/**
|
|
13
23
|
* `stop` completes a run and `tool-calls` means the step budget ran out
|
|
14
24
|
* (`stopWhen` is the only other way the loop ends), which leaves it
|
|
@@ -120,6 +130,9 @@ export function runSparkAgent(options) {
|
|
|
120
130
|
},
|
|
121
131
|
execute: async ({ writer }) => {
|
|
122
132
|
let generationError;
|
|
133
|
+
// The tool errors the model was answered with for its own bad calls
|
|
134
|
+
// (`isModelToolCallError`), as the AI SDK words them (`String(error)`).
|
|
135
|
+
const answeredToModel = new Set();
|
|
123
136
|
let stepCount = 0;
|
|
124
137
|
try {
|
|
125
138
|
controller.signal.throwIfAborted();
|
|
@@ -241,8 +254,14 @@ export function runSparkAgent(options) {
|
|
|
241
254
|
writer.merge(generation.toUIMessageStream({
|
|
242
255
|
generateMessageId: () => options.messageId,
|
|
243
256
|
onError: (error) => {
|
|
257
|
+
// Also called for tool errors. A bad call of the model's arrives
|
|
258
|
+
// twice, as its own error and then as the tool error the model
|
|
259
|
+
// is sent (that error's `String`); neither fails the run.
|
|
260
|
+
if (isModelToolCallError(error))
|
|
261
|
+
answeredToModel.add(String(error));
|
|
244
262
|
// streamText's onError callback may run later on another stream branch.
|
|
245
|
-
|
|
263
|
+
else if (!(typeof error === "string" && answeredToModel.has(error)))
|
|
264
|
+
generationError = error;
|
|
246
265
|
return errorMessage(error);
|
|
247
266
|
},
|
|
248
267
|
sendReasoning: true,
|