122d6ed39eb355f2d6f9f4cd475188d064ac6130

Author
TheEdgeOfRage <git@theedgeofrage.com>
Committer
TheEdgeOfRage <git@theedgeofrage.com>
Date

Message

Preserve whole llm response

Diff

 1diff --git a/src/llm.ts b/src/llm.ts
 2index 1402edeac5ec13fa3ea0d1c44cff2b14ce22b125..dd81429dc3b39714b62e2923622a6c7f4c208deb 100644
 3--- a/src/llm.ts
 4+++ b/src/llm.ts
 5@@ -17,7 +17,7 @@ export function parseLLMResponse(content: string): Decision | undefined {
 6     if (d !== "allow" && d !== "deny" && d !== "ask") return undefined
 7     return {
 8       decision: d,
 9-      reason: ((data.reason as string) ?? "No reason provided").slice(0, 200),
10+      reason: (data.reason as string) ?? "No reason provided",
11       category: (data.category as string) ?? "uncertain",
12     }
13   } catch {
14diff --git a/test/llm-response.test.ts b/test/llm-response.test.ts
15index 4a1c8ba2b4383b91c00d7bc19cd7a5f2ce377fde..b7dbd3ffe35faeefe02327d5ba9742a35460c57c 100644
16--- a/test/llm-response.test.ts
17+++ b/test/llm-response.test.ts
18@@ -37,12 +37,12 @@ describe("parseLLMResponse", () => {
19     expect(parseLLMResponse('{"decision":"allow"')).toBeUndefined()
20   })
21 
22-  test("truncates long reason to 200 chars", () => {
23+  test("preserves a long reason", () => {
24     const long = "x".repeat(300)
25     const d = parseLLMResponse(
26       `{"decision":"allow","reason":"${long}","category":"read_only"}`,
27     )
28-    expect(d!.reason).toHaveLength(200)
29+    expect(d!.reason).toBe(long)
30   })
31 
32   test("defaults missing category to uncertain", () => {