From b7a16b819c3724298b399cfcb2f2e342c6028b1c Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Mon, 8 Jun 2026 01:26:40 +0800 Subject: [PATCH] still wip for claude tool calling --- koboldcpp.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/koboldcpp.py b/koboldcpp.py index bd646fd24..2217b2e1b 100644 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -6854,8 +6854,13 @@ Change Mode
raw_args = json.loads(raw_args) except Exception: raw_args = {} - tc_block = {"type": "tool_use", "id": tool_call.get("id", f"toolu_{random.randint(10000,99999)}"), "name": func.get("name", ""), "input": raw_args} + tc_id = tool_call.get("id", f"toolu_{random.randint(10000,99999)}") + tc_name = func.get("name", "") + # Start block with EMPTY input — the actual args come in the delta + tc_block = {"type": "tool_use", "id": tc_id, "name": tc_name, "input": {}} self.wfile.write(f'event: content_block_start\ndata: {json.dumps({"type":"content_block_start","index":block_index,"content_block":tc_block})}\n\n'.encode()) + # Deliver the args as a single input_json_delta + self.wfile.write(f'event: content_block_delta\ndata: {json.dumps({"type":"content_block_delta","index":block_index,"delta":{"type":"input_json_delta","partial_json":json.dumps(raw_args)}})}\n\n'.encode()) self.wfile.write(f'event: content_block_stop\ndata: {json.dumps({"type":"content_block_stop","index":block_index})}\n\n'.encode()) block_index += 1 else: