import io,json,sys,threading,unittest from pathlib import Path sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'scripts')) from nao_agent_task import _model_json class ThinkingTimeoutTest(unittest.TestCase): def test_valid_slow_local_thinking_plan_is_not_abandoned_at_thirty_seconds(self): calls=[] def provider(request,timeout): calls.append(timeout) if timeout<50:raise TimeoutError('fixture: correct answer arrives at 49 seconds') return io.BytesIO(json.dumps({'model':'qwen3.8-27b-local','choices':[{'finish_reason':'stop','message':{'content':'{"goal":"compare formal quality"}'}}]}).encode()) result=_model_json(base_url='http://127.0.0.1:1/v1',api_key='fixture',model='qwen3.8-27b-local',system='fixture',payload={},cancel_event=threading.Event(),opener=provider) self.assertEqual(result,{'goal':'compare formal quality'}) self.assertEqual(len(calls),1) from nao_runtime_policy import REQUEST_TIMEOUT_SECONDS self.assertLessEqual(calls[0],REQUEST_TIMEOUT_SECONDS) if __name__=='__main__':unittest.main()