Skip to content

Commit a7d958e

Browse files
Akshayclaude
authored andcommitted
test(answer_commit): cover readings and asked sent as JSON strings (#1700)
Addresses review: assert stringified readings and asked are decoded into result metadata. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WyL6JbJvKGuJD8gT1BWVx3
1 parent a90c977 commit a7d958e

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎packages/opencode/test/altimate/tools/answer-commit.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ describe("answer_commit JSON-string tolerance (#1700)", () => {
8787
)
8888
})
8989

90+
test("readings and asked sent as JSON strings are decoded into metadata", async () => {
91+
const readings = [{ clause: "order counts", reading: "distinct orders", result_summary: "99", decided_by: "request" }]
92+
const tool = await initTool(AnswerCommit.AnswerCommitTool)
93+
const result = await tool.execute(
94+
{ basis, fields, asked: '["Is anything wrong"]', readings: JSON.stringify(readings) },
95+
context,
96+
)
97+
expect(result.metadata.readings).toEqual(readings)
98+
expect(result.metadata.asked).toEqual(["Is anything wrong"])
99+
expect(result.output).toBe(AnswerCommit.renderAnswer({ basis, fields }))
100+
})
101+
90102
test("a JSON string that is not valid JSON is still rejected with the normal error", async () => {
91103
const payload = { basis, fields: '[{"name": "diagnosis", "value": 1}' }
92104
expect(() => AnswerCommit.renderAnswer(payload)).toThrow(/fields.*expected array/i)

0 commit comments

Comments
 (0)