Skip to content

Commit 012ab2b

Browse files
authored
Merge pull request #103 from odefun/feat/goose-result-spacing-177158
fix: preserve Goose result spacing and bump version
2 parents c7edd4a + 30cbab9 commit 012ab2b

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ode",
3-
"version": "0.0.70",
3+
"version": "0.0.71",
44
"description": "Coding anywhere with your coding agents connected",
55
"module": "packages/core/index.ts",
66
"type": "module",

packages/agents/goose/client.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,16 @@ function publishGooseRecordAsSessionEvents(record: GooseJsonRecord, fallbackSess
101101
}
102102

103103
function textFromRecord(record: GooseJsonRecord): string {
104-
if (typeof record.result === "string" && record.result.trim()) return record.result.trim();
105-
if (typeof record.output === "string" && record.output.trim()) return record.output.trim();
106-
if (typeof record.text === "string" && record.text.trim()) return record.text.trim();
107-
if (typeof record.content === "string" && record.content.trim()) return record.content.trim();
104+
if (typeof record.result === "string" && record.result.trim()) return record.result;
105+
if (typeof record.output === "string" && record.output.trim()) return record.output;
106+
if (typeof record.text === "string" && record.text.trim()) return record.text;
107+
if (typeof record.content === "string" && record.content.trim()) return record.content;
108108
const content = record.message?.content ?? [];
109109
const joined = content
110110
.filter((part) => part?.type === "text")
111111
.map((part) => part.text ?? "")
112-
.join("")
113-
.trim();
114-
return joined;
112+
.join("");
113+
return joined.trim() ? joined : "";
115114
}
116115

117116
function isPlaceholderResult(text: string): boolean {
@@ -138,7 +137,7 @@ function stitchAssistantChunks(chunks: string[]): string {
138137
return stitched;
139138
}
140139

141-
function parseGooseResponse(output: string): {
140+
export function parseGooseResponse(output: string): {
142141
text: string;
143142
sessionId?: string;
144143
} {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { describe, expect, it } from "bun:test";
2+
import { parseGooseResponse } from "../goose/client";
3+
4+
describe("goose response parsing", () => {
5+
it("preserves whitespace across assistant chunks", () => {
6+
const output = [
7+
JSON.stringify({ type: "assistant", text: "Hi!" }),
8+
JSON.stringify({ type: "assistant", text: " How" }),
9+
JSON.stringify({ type: "assistant", text: " can" }),
10+
JSON.stringify({ type: "assistant", text: " I" }),
11+
JSON.stringify({ type: "assistant", text: " help" }),
12+
JSON.stringify({ type: "assistant", text: " you" }),
13+
JSON.stringify({ type: "assistant", text: " today?" }),
14+
].join("\n");
15+
16+
const parsed = parseGooseResponse(output);
17+
expect(parsed.text).toBe("Hi! How can I help you today?");
18+
});
19+
});

0 commit comments

Comments
 (0)