refactor: use backend chat sessions

This commit is contained in:
2026-06-04 15:02:27 +08:00
parent 20ca410e0a
commit e60e1f6453
9 changed files with 91 additions and 178 deletions
+2 -2
View File
@@ -103,11 +103,11 @@ describe("streamAgentChat", () => {
});
});
it("parses legacy tool_call arguments when params is empty", async () => {
it("parses tool_call arguments when params is empty", async () => {
apiFetch.mockResolvedValue({
ok: true,
body: makeStream([
'event: tool_call\ndata: {"conversationId":"agent-1e75dd01-29e","tool":"locate_features","params":{},"arguments":"{\\"ids\\":[\\"142902\\"],\\"feature_type\\":\\"junction\\"}"}\n\n',
'event: tool_call\ndata: {"session_id":"agent-1e75dd01-29e","tool":"locate_features","params":{},"arguments":"{\\"ids\\":[\\"142902\\"],\\"feature_type\\":\\"junction\\"}"}\n\n',
'event: done\ndata: {"session_id":"agent-1e75dd01-29e"}\n\n',
]),
});
+1 -2
View File
@@ -163,7 +163,6 @@ export const streamAgentChat = async ({
try {
const parsed = JSON.parse(data) as {
session_id?: string;
conversationId?: string;
content?: string;
message?: string;
detail?: string;
@@ -223,7 +222,7 @@ export const streamAgentChat = async ({
} else if (event === "tool_call") {
onEvent({
type: "tool_call",
sessionId: parsed.session_id ?? parsed.conversationId ?? "",
sessionId: parsed.session_id ?? "",
tool: parsed.tool ?? "",
params: resolveToolParams(parsed.params, parsed.arguments),
});