Refactor UI modules and harden run/API behavior
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { parseActorExecutionResultFromModelOutput } from "../src/ui/provider-executor.js";
|
||||
import { parseActorExecutionResultFromModelOutput } from "../src/agents/provider-executor.js";
|
||||
|
||||
test("parseActorExecutionResultFromModelOutput parses strict JSON payload", () => {
|
||||
const parsed = parseActorExecutionResultFromModelOutput({
|
||||
@@ -64,3 +64,42 @@ test("parseActorExecutionResultFromModelOutput falls back when response is not J
|
||||
assert.equal(parsed.status, "success");
|
||||
assert.equal(parsed.payload?.assistantResponse, "Implemented update successfully.");
|
||||
});
|
||||
|
||||
test("parseActorExecutionResultFromModelOutput preserves status when optional fields are malformed", () => {
|
||||
const parsed = parseActorExecutionResultFromModelOutput({
|
||||
rawText: JSON.stringify({
|
||||
status: "failure",
|
||||
payload: {
|
||||
reason: "hard failure",
|
||||
},
|
||||
stateFlags: {
|
||||
retryable: false,
|
||||
invalid_flag: "nope",
|
||||
},
|
||||
stateMetadata: "not-an-object",
|
||||
events: [
|
||||
{
|
||||
type: "validation_failed",
|
||||
payload: {
|
||||
summary: "failed",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 123,
|
||||
},
|
||||
],
|
||||
failureKind: "not-valid",
|
||||
failureCode: 403,
|
||||
}),
|
||||
});
|
||||
|
||||
assert.equal(parsed.status, "failure");
|
||||
assert.equal(parsed.payload?.reason, "hard failure");
|
||||
assert.equal(parsed.stateFlags?.retryable, false);
|
||||
assert.equal(parsed.stateFlags && "invalid_flag" in parsed.stateFlags, false);
|
||||
assert.equal(parsed.stateMetadata, undefined);
|
||||
assert.equal(parsed.events?.length, 1);
|
||||
assert.equal(parsed.events?.[0]?.type, "validation_failed");
|
||||
assert.equal(parsed.failureKind, undefined);
|
||||
assert.equal(parsed.failureCode, undefined);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user