Capture text from step_finish message field in parse
OpenCode outputs the final response in step_finish.part.message, not just as type:text events. Added parsing of part.message to ensure the summary is captured when the agent responds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,19 @@ describe("parseOpenCodeJsonl", () => {
|
|||||||
expect(result.costUsd).toBeCloseTo(0.001);
|
expect(result.costUsd).toBeCloseTo(0.001);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("captures text from step_finish message field", () => {
|
||||||
|
const stdout = [
|
||||||
|
JSON.stringify({
|
||||||
|
type: "step_finish",
|
||||||
|
part: { message: "Final response text", tokens: { input: 10, output: 5 } },
|
||||||
|
}),
|
||||||
|
].join("\n");
|
||||||
|
|
||||||
|
const result = parseOpenCodeJsonl(stdout);
|
||||||
|
|
||||||
|
expect(result.summary).toBe("Final response text");
|
||||||
|
});
|
||||||
|
|
||||||
it("captures errors from error type events", () => {
|
it("captures errors from error type events", () => {
|
||||||
const stdout = [
|
const stdout = [
|
||||||
JSON.stringify({ type: "error", error: { message: "Something went wrong" } }),
|
JSON.stringify({ type: "error", error: { message: "Something went wrong" } }),
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ export function parseOpenCodeJsonl(stdout: string) {
|
|||||||
|
|
||||||
if (type === "step_finish") {
|
if (type === "step_finish") {
|
||||||
const part = parseObject(event.part);
|
const part = parseObject(event.part);
|
||||||
|
const text = asString(part.message, "").trim();
|
||||||
|
if (text) messages.push(text);
|
||||||
const tokens = parseObject(part.tokens);
|
const tokens = parseObject(part.tokens);
|
||||||
const cache = parseObject(tokens.cache);
|
const cache = parseObject(tokens.cache);
|
||||||
usage.inputTokens += asNumber(tokens.input, 0);
|
usage.inputTokens += asNumber(tokens.input, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user