diff options
| author | t <t@tjp.lol> | 2026-06-10 16:46:30 -0600 |
|---|---|---|
| committer | t <t@tjp.lol> | 2026-06-10 16:46:48 -0600 |
| commit | b435cf06b78853bec87bf238f526bc60679d7712 (patch) | |
| tree | 0c4191f24730f9a0336accb701d627450483c9cf /libpanto/src/anthropic_messages_json.zig | |
| parent | cee08918509689adbdbd26b6384d5ef3a47e91a2 (diff) | |
fix anthropic thinking effort json placement
Diffstat (limited to 'libpanto/src/anthropic_messages_json.zig')
| -rw-r--r-- | libpanto/src/anthropic_messages_json.zig | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libpanto/src/anthropic_messages_json.zig b/libpanto/src/anthropic_messages_json.zig index 3ad6069..99d89eb 100644 --- a/libpanto/src/anthropic_messages_json.zig +++ b/libpanto/src/anthropic_messages_json.zig @@ -55,7 +55,7 @@ pub fn serializeRequest( // Extended thinking configuration. // `.disabled` — omit the field entirely. // `.enabled` — manual budget: { type, budget_tokens, display }. - // `.adaptive` — adaptive mode: { type, display } + top-level effort. + // `.adaptive` — adaptive mode: { type, display } + output_config.effort. switch (cfg.thinking) { .disabled => {}, .enabled => { @@ -82,8 +82,11 @@ pub fn serializeRequest( try s.objectField("display"); try s.write("summarized"); try s.endObject(); + try s.objectField("output_config"); + try s.beginObject(); try s.objectField("effort"); try s.write(@tagName(cfg.effort)); + try s.endObject(); }, } @@ -1285,7 +1288,9 @@ test "serializeRequest - thinking adaptive default effort" { try testing.expectEqualStrings("adaptive", th.get("type").?.string); try testing.expectEqualStrings("summarized", th.get("display").?.string); try testing.expect(th.get("budget_tokens") == null); - try testing.expectEqualStrings("medium", root.get("effort").?.string); + try testing.expect(root.get("effort") == null); + const oc = root.get("output_config").?.object; + try testing.expectEqualStrings("medium", oc.get("effort").?.string); } test "serializeRequest - thinking adaptive explicit effort levels" { @@ -1312,7 +1317,8 @@ test "serializeRequest - thinking adaptive explicit effort levels" { var parsed = try std.json.parseFromSlice(std.json.Value, allocator, body, .{}); defer parsed.deinit(); - try testing.expectEqualStrings(entry.name, parsed.value.object.get("effort").?.string); + const oc = parsed.value.object.get("output_config").?.object; + try testing.expectEqualStrings(entry.name, oc.get("effort").?.string); } } |
