mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 15:24:58 +00:00
refactor(agents): dedupe model and tool test helpers
This commit is contained in:
@@ -40,6 +40,19 @@ describe("buildEmbeddedRunPayloads", () => {
|
||||
expect(payloads[0]?.text).toBe(OVERLOADED_FALLBACK_TEXT);
|
||||
};
|
||||
|
||||
function expectNoSyntheticCompletionForSession(sessionKey: string) {
|
||||
const payloads = buildPayloads({
|
||||
sessionKey,
|
||||
toolMetas: [{ toolName: "write", meta: "/tmp/out.md" }],
|
||||
lastAssistant: makeAssistant({
|
||||
stopReason: "stop",
|
||||
errorMessage: undefined,
|
||||
content: [],
|
||||
}),
|
||||
});
|
||||
expect(payloads).toHaveLength(0);
|
||||
}
|
||||
|
||||
it("suppresses raw API error JSON when the assistant errored", () => {
|
||||
const payloads = buildPayloads({
|
||||
assistantTexts: [errorJson],
|
||||
@@ -140,31 +153,11 @@ describe("buildEmbeddedRunPayloads", () => {
|
||||
});
|
||||
|
||||
it("does not add synthetic completion text for channel sessions", () => {
|
||||
const payloads = buildPayloads({
|
||||
sessionKey: "agent:main:discord:channel:c123",
|
||||
toolMetas: [{ toolName: "write", meta: "/tmp/out.md" }],
|
||||
lastAssistant: makeAssistant({
|
||||
stopReason: "stop",
|
||||
errorMessage: undefined,
|
||||
content: [],
|
||||
}),
|
||||
});
|
||||
|
||||
expect(payloads).toHaveLength(0);
|
||||
expectNoSyntheticCompletionForSession("agent:main:discord:channel:c123");
|
||||
});
|
||||
|
||||
it("does not add synthetic completion text for group sessions", () => {
|
||||
const payloads = buildPayloads({
|
||||
sessionKey: "agent:main:telegram:group:g123",
|
||||
toolMetas: [{ toolName: "write", meta: "/tmp/out.md" }],
|
||||
lastAssistant: makeAssistant({
|
||||
stopReason: "stop",
|
||||
errorMessage: undefined,
|
||||
content: [],
|
||||
}),
|
||||
});
|
||||
|
||||
expect(payloads).toHaveLength(0);
|
||||
expectNoSyntheticCompletionForSession("agent:main:telegram:group:g123");
|
||||
});
|
||||
|
||||
it("does not add synthetic completion text when messaging tool already delivered output", () => {
|
||||
|
||||
Reference in New Issue
Block a user