Skip to content

Commit a5592e9

Browse files
committed
fixes #33
1 parent f4260c9 commit a5592e9

File tree

3 files changed

+104
-86
lines changed

3 files changed

+104
-86
lines changed

cachy.jsonl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,5 @@
5858
{"key": "6e9762a7", "response": "{\"model\":\"claude-sonnet-4-5-20250929\",\"id\":\"msg_0184Pnor6Nkd8sgiGHjBUikA\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"We just calculated the mathematical expression **((10 + 5) * 3) / (2 + 1)** step by step!\\n\\nHere's what happened:\\n\\n1. **First**, I calculated the two additions in parallel:\\n - 10 + 5 = 15\\n - 2 + 1 = 3\\n\\n2. **Then**, I multiplied the first result by 3:\\n - 15 * 3 = 45\\n\\n3. **Finally**, I was about to divide 45 by 3 to get the final answer, but you interrupted me before I completed that last step.\\n\\nSo we were working through a math problem using the available calculator functions (add, multiply, divide), breaking it down into steps and making calls in parallel when operations were independent of each other. The final answer would be 45 / 3 = **15**.\"}],\"stop_reason\":\"end_turn\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":1284,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":199,\"service_tier\":\"standard\"}}"}
5959
{"key": "76164dc7", "response": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"model\":\"claude-sonnet-4-5-20250929\",\"id\":\"msg_01CZziGjQUV1KktxCLtPhnTP\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":4,\"cache_creation_input_tokens\":1622,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":1622,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":1,\"service_tier\":\"standard\"}} }\n\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"} }\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"Hi\"} }\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" there! How can\"} }\n\nevent: ping\ndata: {\"type\": \"ping\"}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" I help you today?\"} }\n\nevent: ping\ndata: {\"type\": \"ping\"}\n\nevent: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0 }\n\nevent: ping\ndata: {\"type\": \"ping\"}\n\nevent: ping\ndata: {\"type\": \"ping\"}\n\nevent: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":4,\"cache_creation_input_tokens\":1622,\"cache_read_input_tokens\":0,\"output_tokens\":13} }\n\nevent: message_stop\ndata: {\"type\":\"message_stop\" }\n\n"}
6060
{"key": "5c8485a6", "response": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"model\":\"claude-sonnet-4-5-20250929\",\"id\":\"msg_01RdWq1HZiktb4MwDU7W8H5r\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":4,\"cache_creation_input_tokens\":14,\"cache_read_input_tokens\":1622,\"cache_creation\":{\"ephemeral_5m_input_tokens\":14,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":13,\"service_tier\":\"standard\"}} }\n\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"} }\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"Goodbye! Feel free to come back if you have any questions\"} }\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\".\"} }\n\nevent: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0 }\n\nevent: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":4,\"cache_creation_input_tokens\":14,\"cache_read_input_tokens\":1622,\"output_tokens\":17} }\n\nevent: message_stop\ndata: {\"type\":\"message_stop\" }\n\n"}
61+
{"key": "a22b9fd8", "response": "{\n \"candidates\": [\n {\n \"content\": {\n \"parts\": [\n {\n \"text\": \"\\nThe `simple_add` tool was used to calculate 5 + 3.\\nThe tool returned the result 8.\\n\\nTherefore, 5 + 3 = 8.\"\n }\n ],\n \"role\": \"model\"\n },\n \"finishReason\": \"STOP\",\n \"index\": 0\n }\n ],\n \"usageMetadata\": {\n \"promptTokenCount\": 159,\n \"candidatesTokenCount\": 38,\n \"totalTokenCount\": 197,\n \"promptTokensDetails\": [\n {\n \"modality\": \"TEXT\",\n \"tokenCount\": 159\n }\n ]\n },\n \"modelVersion\": \"gemini-2.5-flash\",\n \"responseId\": \"ygzzaMvxIrGY1e8PxZeQkAU\"\n}\n"}
62+
{"key": "3b980a69", "response": "{\"model\":\"claude-sonnet-4-5-20250929\",\"id\":\"msg_01LyeL5YjfosAxiaeSriXhPw\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[{\"type\":\"text\",\"text\":\"We just calculated the mathematical expression **((10 + 5) * 3) / (2 + 1)** step by step!\\n\\nHere's what happened:\\n\\n1. **First**, I calculated the two additions in parentheses:\\n - 10 + 5 = 15\\n - 2 + 1 = 3\\n\\n2. **Then**, I multiplied the first result by 3:\\n - 15 * 3 = 45\\n\\n3. **Finally**, I was about to divide 45 by 3 to get the final answer (which would be 15), but you asked me this question before I completed that last step!\\n\\nSo we were working through a math problem using function calls, following the proper order of operations (parentheses first, then multiplication/division from left to right).\"}],\"stop_reason\":\"end_turn\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":1262,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"output_tokens\":188,\"service_tier\":\"standard\"}}"}

lisette/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ def fmt2hist(outp:str)->list:
137137
lm,hist = Message(),[]
138138
spt = re_tools.split(outp)
139139
for txt,_,tooljson in chunked(spt, 3, pad=True):
140-
if txt.strip(): hist.append(lm:=Message(txt.strip()))
140+
txt = txt.strip() if tooljson or txt.strip() else '.'
141+
hist.append(lm:=Message(txt))
141142
if tooljson:
142143
tcr = _extract_tool(tooljson)
143144
if not hist: hist.append(lm) # if LLM calls a tool without talking

0 commit comments

Comments
 (0)