@@ -112,6 +112,7 @@ def reply(context, &update_blk)
112112
113113 allow_partial_tool_calls = persona . allow_partial_tool_calls?
114114 existing_tools = Set . new
115+ current_thinking = [ ]
115116
116117 result =
117118 llm . generate (
@@ -149,7 +150,17 @@ def reply(context, &update_blk)
149150 needs_newlines = false
150151 end
151152
152- process_tool ( tool , raw_context , llm , cancel , update_blk , prompt , context )
153+ process_tool (
154+ tool : tool ,
155+ raw_context : raw_context ,
156+ llm : llm ,
157+ cancel : cancel ,
158+ update_blk : update_blk ,
159+ prompt : prompt ,
160+ context : context ,
161+ current_thinking : current_thinking ,
162+ )
163+
153164 tools_ran += 1
154165 ongoing_chain &&= tool . chain_next_response?
155166
@@ -167,6 +178,7 @@ def reply(context, &update_blk)
167178 if !partial . partial?
168179 # this will be dealt with later
169180 raw_context << partial
181+ current_thinking << partial
170182 end
171183 else
172184 update_blk . call ( partial , cancel )
@@ -222,7 +234,16 @@ def embed_thinking(raw_context)
222234 embedded_thinking
223235 end
224236
225- def process_tool ( tool , raw_context , llm , cancel , update_blk , prompt , context )
237+ def process_tool (
238+ tool :,
239+ raw_context :,
240+ llm :,
241+ cancel :,
242+ update_blk :,
243+ prompt :,
244+ context :,
245+ current_thinking :
246+ )
226247 tool_call_id = tool . tool_call_id
227248 invocation_result_json = invoke_tool ( tool , llm , cancel , context , &update_blk ) . to_json
228249
@@ -233,6 +254,17 @@ def process_tool(tool, raw_context, llm, cancel, update_blk, prompt, context)
233254 name : tool . name ,
234255 }
235256
257+ if current_thinking . present?
258+ current_thinking . each do |thinking |
259+ if thinking . redacted
260+ tool_call_message [ :redacted_thinking_signature ] = thinking . signature
261+ else
262+ tool_call_message [ :thinking ] = thinking . message
263+ tool_call_message [ :thinking_signature ] = thinking . signature
264+ end
265+ end
266+ end
267+
236268 tool_message = {
237269 type : :tool ,
238270 id : tool_call_id ,
0 commit comments