@@ -122,3 +122,172 @@ def test_passthrough_and_single_call_incompatibility():
122
122
# LLMRails(config=config)
123
123
#
124
124
# assert "You must provide a `self_check_facts` prompt" in str(exc_info.value)
125
+
126
+
127
+ def test_reasoning_traces_with_explicit_dialog_rails ():
128
+ """Test that reasoning traces cannot be enabled when dialog rails are explicitly configured."""
129
+
130
+ with pytest .raises (ValueError ) as exc_info :
131
+ config = RailsConfig .from_content (
132
+ yaml_content = """
133
+ models:
134
+ - type: main
135
+ engine: openai
136
+ model: gpt-3.5-turbo-instruct
137
+ reasoning_config:
138
+ remove_thinking_traces: false
139
+ rails:
140
+ dialog:
141
+ single_call:
142
+ enabled: true
143
+ """ ,
144
+ )
145
+ LLMRails (config = config )
146
+
147
+ assert "Reasoning traces cannot be enabled when dialog rails are present" in str (
148
+ exc_info .value
149
+ )
150
+
151
+
152
+ def test_reasoning_traces_without_dialog_rails ():
153
+ """Test that reasoning traces can be enabled when no dialog rails are present."""
154
+
155
+ config = RailsConfig .from_content (
156
+ yaml_content = """
157
+ models:
158
+ - type: main
159
+ engine: openai
160
+ model: gpt-3.5-turbo-instruct
161
+ reasoning_config:
162
+ remove_thinking_traces: false
163
+ """ ,
164
+ )
165
+ LLMRails (config = config )
166
+
167
+
168
+ def test_dialog_rails_without_reasoning_traces ():
169
+ """Test that dialog rails can be enabled when reasoning traces are not enabled."""
170
+
171
+ config = RailsConfig .from_content (
172
+ yaml_content = """
173
+ models:
174
+ - type: main
175
+ engine: openai
176
+ model: gpt-3.5-turbo-instruct
177
+ rails:
178
+ dialog:
179
+ single_call:
180
+ enabled: true
181
+ """ ,
182
+ )
183
+ LLMRails (config = config )
184
+
185
+
186
+ def test_reasoning_traces_with_implicit_dialog_rails_user_bot_messages ():
187
+ """Test that reasoning traces cannot be enabled when dialog rails are implicitly enabled thru user/bot messages."""
188
+
189
+ with pytest .raises (ValueError ) as exc_info :
190
+ config = RailsConfig .from_content (
191
+ yaml_content = """
192
+ models:
193
+ - type: main
194
+ engine: openai
195
+ model: gpt-3.5-turbo-instruct
196
+ reasoning_config:
197
+ remove_thinking_traces: false
198
+ """ ,
199
+ colang_content = """
200
+ define user express greeting
201
+ "hello"
202
+ "hi"
203
+
204
+ define bot express greeting
205
+ "Hello there!"
206
+
207
+ define flow
208
+ user express greeting
209
+ bot express greeting
210
+ """ ,
211
+ )
212
+ LLMRails (config = config )
213
+
214
+ assert "Reasoning traces cannot be enabled when dialog rails are present" in str (
215
+ exc_info .value
216
+ )
217
+
218
+
219
+ def test_reasoning_traces_with_implicit_dialog_rails_flows_only ():
220
+ """Test that reasoning traces cannot be enabled when dialog rails are implicitly enabled thru flows only."""
221
+
222
+ with pytest .raises (ValueError ) as exc_info :
223
+ config = RailsConfig .from_content (
224
+ yaml_content = """
225
+ models:
226
+ - type: main
227
+ engine: openai
228
+ model: gpt-3.5-turbo-instruct
229
+ reasoning_config:
230
+ remove_thinking_traces: false
231
+ """ ,
232
+ colang_content = """
233
+ define flow
234
+ user express greeting
235
+ bot express greeting
236
+ """ ,
237
+ )
238
+ LLMRails (config = config )
239
+
240
+ assert "Reasoning traces cannot be enabled when dialog rails are present" in str (
241
+ exc_info .value
242
+ )
243
+
244
+
245
+ def test_reasoning_traces_with_implicit_dialog_rails_user_messages_only ():
246
+ """Test that reasoning traces cannot be enabled when dialog rails are implicitly enabled thru user messages only."""
247
+
248
+ with pytest .raises (ValueError ) as exc_info :
249
+ config = RailsConfig .from_content (
250
+ yaml_content = """
251
+ models:
252
+ - type: main
253
+ engine: openai
254
+ model: gpt-3.5-turbo-instruct
255
+ reasoning_config:
256
+ remove_thinking_traces: false
257
+ """ ,
258
+ colang_content = """
259
+ define user express greeting
260
+ "hello"
261
+ "hi"
262
+ """ ,
263
+ )
264
+ LLMRails (config = config )
265
+
266
+ assert "Reasoning traces cannot be enabled when dialog rails are present" in str (
267
+ exc_info .value
268
+ )
269
+
270
+
271
+ def test_reasoning_traces_with_implicit_dialog_rails_bot_messages_only ():
272
+ """Test that reasoning traces cannot be enabled when dialog rails are implicitly enabled thru bot messages only."""
273
+
274
+ with pytest .raises (ValueError ) as exc_info :
275
+ config = RailsConfig .from_content (
276
+ yaml_content = """
277
+ models:
278
+ - type: main
279
+ engine: openai
280
+ model: gpt-3.5-turbo-instruct
281
+ reasoning_config:
282
+ remove_thinking_traces: false
283
+ """ ,
284
+ colang_content = """
285
+ define bot express greeting
286
+ "Hello there!"
287
+ """ ,
288
+ )
289
+ LLMRails (config = config )
290
+
291
+ assert "Reasoning traces cannot be enabled when dialog rails are present" in str (
292
+ exc_info .value
293
+ )
0 commit comments