@@ -35,9 +35,9 @@ def test_rewoo_plan_parses_valid_bullets_and_records_successful_tool_call():
3535
3636 # Successful tool call recorded once
3737 assert result .tool_calls and result .tool_calls [0 ] == {"tool_id" : "t1" , "summary" : "Tool One" }
38- # Transcript contains remembered k1 and executed steps
39- assert "remembered k1" in result .transcript
38+ # Transcript contains executed steps; memory has k1
4039 assert "Executed step:" in result .transcript
40+ assert "k1" in memory
4141
4242
4343def test_rewoo_plan_raises_on_input_before_output ():
@@ -287,6 +287,44 @@ def test_rewoo_selection_invalid_id_records_no_tool_call():
287287 assert result .tool_calls == []
288288
289289
290+ def test_rewoo_history_truncates_step_result_to_8kb ():
291+ # Plan with one TOOL step producing a very large payload
292+ plan_text = "- fetch big (output: k1)"
293+ large_payload = "X" * 50000 # 50KB
294+
295+ class BigTool (DummyTool ):
296+ def __init__ (self , tool_id : str , name : str ):
297+ super ().__init__ (tool_id , name , schema = {})
298+
299+ class BigTools (DummyTools ):
300+ def execute (self , tool , params ): # type: ignore[override]
301+ return large_payload
302+
303+ llm = DummyLLM (
304+ text_queue = [
305+ plan_text , # plan
306+ "TOOL" , # classify
307+ "t1" , # select tool
308+ ],
309+ json_queue = [{}], # params
310+ )
311+ tools = BigTools ([BigTool ("t1" , "Big Tool" )])
312+ memory : Dict [str , Any ] = DictMemory ()
313+
314+ reasoner = ReWOOReasoner (llm = llm , tools = tools , memory = memory )
315+ result = reasoner .run ("goal" )
316+
317+ # Transcript should contain the executed line with truncated payload (~8124 chars)
318+ assert "Executed step:" in result .transcript
319+ executed_lines = [ln for ln in result .transcript .split ("\n " ) if ln .startswith ("Executed step:" )]
320+ assert executed_lines , "Expected at least one executed step line"
321+ line = executed_lines [- 1 ]
322+ # Ensure truncation happened (< original 50k)
323+ assert len (line ) < 20000
324+ # And memory stores full payload (no truncation in memory)
325+ assert memory .get ("k1" ) == large_payload
326+
327+
290328def test_rewoo_param_gen_error_triggers_reflection_and_no_tool_call ():
291329 # Override LLM to raise a ValueError during param generation
292330 class FailParamLLM (DummyLLM ):
0 commit comments