mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-26 07:57:40 +00:00
fix(regression): classify toolcall content as tool output
This commit is contained in:
@@ -43,7 +43,7 @@ describe("message-normalizer", () => {
|
||||
timestamp: 2000,
|
||||
});
|
||||
|
||||
expect(result.role).toBe("assistant");
|
||||
expect(result.role).toBe("toolResult");
|
||||
expect(result.content).toHaveLength(2);
|
||||
expect(result.content[0]).toEqual({
|
||||
type: "text",
|
||||
@@ -88,6 +88,21 @@ describe("message-normalizer", () => {
|
||||
expect(result.role).toBe("toolResult");
|
||||
});
|
||||
|
||||
it("detects tool messages by toolcall content blocks", () => {
|
||||
const result = normalizeMessage({
|
||||
role: "assistant",
|
||||
content: [{ type: "toolcall", name: "Bash", arguments: { command: "pwd" } }],
|
||||
});
|
||||
|
||||
expect(result.role).toBe("toolResult");
|
||||
expect(result.content[0]).toEqual({
|
||||
type: "toolcall",
|
||||
text: undefined,
|
||||
name: "Bash",
|
||||
args: { command: "pwd" },
|
||||
});
|
||||
});
|
||||
|
||||
it("handles missing role", () => {
|
||||
const result = normalizeMessage({ content: "No role" });
|
||||
expect(result.role).toBe("unknown");
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import { stripInboundMetadata } from "../../../../src/auto-reply/reply/strip-inbound-meta.js";
|
||||
import {
|
||||
isToolCallContentType,
|
||||
isToolResultContentType,
|
||||
resolveToolBlockArgs,
|
||||
} from "../../../../src/chat/tool-content.js";
|
||||
@@ -26,7 +27,7 @@ export function normalizeMessage(message: unknown): NormalizedMessage {
|
||||
Array.isArray(contentItems) &&
|
||||
contentItems.some((item) => {
|
||||
const x = item as Record<string, unknown>;
|
||||
return isToolResultContentType(x.type);
|
||||
return isToolResultContentType(x.type) || isToolCallContentType(x.type);
|
||||
});
|
||||
|
||||
const hasToolName = typeof m.toolName === "string" || typeof m.tool_name === "string";
|
||||
|
||||
Reference in New Issue
Block a user