rig-core 0.44.0

An opinionated library for building LLM powered applications.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
use serde_json::{Value, json};

use super::*;
use crate::completion::{GenerationOptions, OnUnsupported, Verbosity};
use crate::error::ProviderError;
use crate::operation::Completion;
use crate::providers::anthropic::completion::{
    CLAUDE_FABLE_5, CLAUDE_HAIKU_4_5, CLAUDE_OPUS_4_6, CLAUDE_OPUS_4_8, CLAUDE_OPUS_5,
    CLAUDE_OPUS_5_5, CLAUDE_SONNET_4_6, CLAUDE_SONNET_5, CLAUDE_SONNET_5_5,
};
use crate::providers::anthropic::wire::AnthropicConfig;
use crate::wire::{Body, Mode, Operation, Wire};

fn wire(model: &str) -> Messages {
    AnthropicConfig::new("sk-test").completion(model)
}

fn gateway(dialect: &crate::providers::anthropic::Dialect, model: &str) -> Messages {
    AnthropicConfig::with_key(dialect, "sk-test").completion(model)
}

/// The body `wire` sends for `request`, prepared as the driver prepares it.
fn sent(wire: &Messages, request: CompletionRequest, mode: Mode) -> Result<Value, ProviderError> {
    let request = Completion::prepare(request, &wire.describe())?;
    let encoded = wire.encode(request, mode)?;
    let Body::Bytes(bytes) = encoded.request.body() else {
        return Err(ProviderError::request("a Messages body is JSON"));
    };
    Ok(serde_json::from_slice(bytes)?)
}

fn request(options: GenerationOptions) -> CompletionRequest {
    CompletionRequest::new("Answer the question")
        .max_tokens(2048)
        .options(options)
}

fn schema() -> crate::schemars::Schema {
    serde_json::from_value(json!({"type": "object", "properties": {"answer": {"type": "string"}}}))
        .expect("a schema")
}

fn refused(result: Result<Value, ProviderError>) -> &'static str {
    match result {
        Err(ProviderError::UnsupportedOption(option)) => match option.option {
            std::borrow::Cow::Borrowed(name) => name,
            std::borrow::Cow::Owned(name) => panic!("a GenerationOptions field, got {name}"),
        },
        other => panic!("expected a refusal, got {other:?}"),
    }
}

/// The catalog holds what each model's encoding reads, found by its id or a
/// dated snapshot of it, never by a later model whose id merely starts with
/// one.
#[test]
fn the_catalog_holds_each_models_thinking_facts() {
    let spec = |model: &str| super::super::completion::spec(model);
    let haiku = spec("claude-haiku-4-5-20251001").expect("listed");
    assert!(haiku.reasoning.levels.is_empty() && haiku.reasoning.budget.is_some());
    assert!(haiku.reasoning.can_disable && !haiku.compat.adaptive_thinking);
    let opus_4_5 = spec("claude-opus-4-5").expect("listed");
    assert_eq!(opus_4_5.reasoning.levels.len(), 3);
    assert!(!opus_4_5.compat.adaptive_thinking);
    let sonnet_4_6 = spec("claude-sonnet-4-6").expect("listed");
    assert!(sonnet_4_6.compat.adaptive_thinking && sonnet_4_6.reasoning.budget.is_some());
    assert!(!sonnet_4_6.reasoning.levels.contains(&Effort::XHigh));
    let opus_4_8 = spec(CLAUDE_OPUS_4_8).expect("listed");
    assert!(opus_4_8.reasoning.budget.is_none());
    assert_eq!(opus_4_8.sampling, Some(crate::catalog::Sampling::Never));
    let sonnet_5_5 = spec(CLAUDE_SONNET_5_5).expect("listed");
    assert_eq!(
        sonnet_5_5.compat.thinking_off.as_deref(),
        Some("between_tools")
    );
    assert!(
        !spec("claude-opus-5-5-20260101")
            .expect("a snapshot")
            .reasoning
            .can_disable
    );
    assert!(!spec(CLAUDE_FABLE_5).expect("listed").reasoning.can_disable);
    assert!(spec(CLAUDE_OPUS_5).expect("listed").reasoning.can_disable);
    assert!(spec("claude-opus-5-50").is_none());
    assert!(spec("custom-model").is_none());
}

/// Ported from #2616 (`typed_thinking_and_effort_serialize_to_the_documented_wire_values`):
/// each class's thinking and effort, as the mapping table states them.
#[test]
fn reasoning_takes_each_classes_documented_shape() {
    let reasoning = |model: &str, reasoning: Reasoning| {
        sent(
            &wire(model),
            request(GenerationOptions::default().reasoning(reasoning)),
            Mode::Unary,
        )
    };
    for (model, effort) in [
        (CLAUDE_OPUS_4_6, Effort::Max),
        (CLAUDE_OPUS_4_8, Effort::XHigh),
        (CLAUDE_SONNET_5, Effort::Low),
        (CLAUDE_OPUS_5_5, Effort::Medium),
        ("custom-model", Effort::High),
    ] {
        let body = reasoning(model, Reasoning::Effort(effort)).expect("the level is taken");
        assert_eq!(body["thinking"]["type"], "adaptive", "{model}");
        assert_eq!(body["output_config"]["effort"], effort.as_str(), "{model}");
    }
    let body = reasoning("claude-opus-4-5", Reasoning::Effort(Effort::High))
        .expect("Opus 4.5 takes an effort");
    assert_eq!(body["output_config"], json!({"effort": "high"}));
    assert!(body.get("thinking").is_none(), "{body}");

    for (model, off) in [
        (CLAUDE_HAIKU_4_5, json!({"type": "disabled"})),
        (CLAUDE_OPUS_5, json!({"type": "disabled"})),
        (CLAUDE_SONNET_5_5, json!({"type": "between_tools"})),
    ] {
        let body = reasoning(model, Reasoning::Off).expect("thinking can be turned off");
        assert_eq!(body["thinking"], off, "{model}");
    }
    let body = reasoning(CLAUDE_OPUS_4_6, Reasoning::Budget { tokens: 1024 })
        .expect("Opus 4.6 takes a budget");
    assert_eq!(
        body["thinking"],
        json!({"type": "enabled", "budget_tokens": 1024})
    );

    for (model, refused_reasoning) in [
        (CLAUDE_OPUS_5_5, Reasoning::Off),
        (CLAUDE_FABLE_5, Reasoning::Off),
        (CLAUDE_HAIKU_4_5, Reasoning::Effort(Effort::High)),
        (CLAUDE_OPUS_4_6, Reasoning::Effort(Effort::XHigh)),
        (CLAUDE_OPUS_4_8, Reasoning::Effort(Effort::Minimal)),
        (CLAUDE_OPUS_4_8, Reasoning::Budget { tokens: 2048 }),
        (CLAUDE_HAIKU_4_5, Reasoning::Budget { tokens: 512 }),
        (CLAUDE_HAIKU_4_5, Reasoning::Budget { tokens: 4096 }),
    ] {
        assert_eq!(
            refused(reasoning(model, refused_reasoning)),
            "reasoning",
            "{model}: {refused_reasoning:?}"
        );
    }
}

/// Ported from #1480 (`adaptive_parameters_validate_legacy_models_without_rejecting_newer_ones`):
/// a model without adaptive thinking refuses an effort level, and the newer
/// models, or one the table does not name, take every level they list.
#[test]
fn legacy_models_refuse_an_effort_newer_ones_take_it() {
    for model in ["claude-sonnet-4-5", CLAUDE_HAIKU_4_5] {
        let result = sent(
            &wire(model),
            request(GenerationOptions::default().reasoning(Effort::Max)),
            Mode::Unary,
        );
        assert_eq!(refused(result), "reasoning", "{model}");
    }
    for model in [
        CLAUDE_OPUS_4_6,
        CLAUDE_SONNET_4_6,
        CLAUDE_OPUS_4_8,
        "custom-model",
    ] {
        let body = sent(
            &wire(model),
            request(GenerationOptions::default().reasoning(Effort::Max)),
            Mode::Unary,
        )
        .unwrap_or_else(|error| panic!("{model}: {error}"));
        assert_eq!(body["output_config"]["effort"], "max", "{model}");
    }
}

/// Claude Opus 4, Opus 4.1 and Sonnet 4 take no effort level (the effort
/// page's supported models list none of them): every level is refused, as
/// for the other budget-only models, and a budget is still sent.
#[test]
fn claude_4_0_and_4_1_refuse_an_effort_and_take_a_budget() {
    for model in [
        "claude-opus-4-0",
        "claude-opus-4-1",
        "claude-sonnet-4-0",
        "claude-opus-4-1-20250805",
        "claude-sonnet-4-20250514",
    ] {
        for effort in [
            Effort::Low,
            Effort::Medium,
            Effort::High,
            Effort::XHigh,
            Effort::Max,
        ] {
            let result = sent(
                &wire(model),
                request(GenerationOptions::default().reasoning(effort)),
                Mode::Unary,
            );
            assert_eq!(refused(result), "reasoning", "{model}");
        }
        let body = sent(
            &wire(model),
            request(GenerationOptions::default().reasoning(Reasoning::Budget { tokens: 1024 })),
            Mode::Unary,
        )
        .unwrap_or_else(|error| panic!("{model}: {error}"));
        assert_eq!(body["thinking"]["budget_tokens"], 1024, "{model}");
    }
}

/// The refusal of an effort on Claude Opus 4, Opus 4.1 and Sonnet 4 rests
/// on catalog data alone, so it follows the policy: under `Ignore` the
/// request goes out without the effort, with one warning.
#[test]
fn claude_4_0_and_4_1_skip_an_effort_under_ignore() {
    for model in ["claude-opus-4-0", "claude-opus-4-1", "claude-sonnet-4-0"] {
        let capture = crate::test_utils::TraceCapture::default();
        let body = tracing::subscriber::with_default(capture.subscriber(), || {
            sent(
                &wire(model),
                request(
                    GenerationOptions::default()
                        .reasoning(Effort::High)
                        .on_unsupported(OnUnsupported::Ignore),
                ),
                Mode::Unary,
            )
        })
        .unwrap_or_else(|error| panic!("{model}: {error}"));
        assert_eq!(body.get("thinking"), None, "{model}: {body}");
        assert_eq!(body.get("output_config"), None, "{model}: {body}");
        let warnings = capture.warnings();
        assert_eq!(warnings.len(), 1, "{model}: {warnings:?}");
        assert!(warnings[0].contains("option=reasoning"), "{warnings:?}");
        assert!(warnings[0].contains(model), "{warnings:?}");
    }
}

#[test]
fn the_remaining_options_take_their_documented_cells() {
    let one =
        |options: GenerationOptions| sent(&wire(CLAUDE_OPUS_4_6), request(options), Mode::Unary);
    let body = one(GenerationOptions::default().top_p(0.5)).expect("Opus 4.6 takes top_p");
    assert_eq!(body["top_p"], 0.5);
    assert_eq!(
        refused(one(GenerationOptions::default().top_p(0.5)).and_then(|_| {
            sent(
                &wire(CLAUDE_OPUS_4_6),
                request(GenerationOptions::default().top_p(0.5)).temperature(0.2),
                Mode::Unary,
            )
        })),
        "top_p"
    );
    let body = one(GenerationOptions::default().stop(["END"])).expect("stop sequences");
    assert_eq!(body["stop_sequences"], json!(["END"]));
    let body =
        one(GenerationOptions::default().service_tier(ServiceTier::Auto)).expect("the auto tier");
    assert_eq!(body["service_tier"], "auto");
    for options in [
        GenerationOptions::default().service_tier(ServiceTier::Priority),
        GenerationOptions::default().service_tier(ServiceTier::Flex),
        GenerationOptions::default().verbosity(Verbosity::Low),
        GenerationOptions::default().seed(1),
    ] {
        assert!(matches!(
            one(options),
            Err(ProviderError::UnsupportedOption(_))
        ));
    }

    // `parallel_tool_calls: false` joins the request's tool choice.
    let tool = crate::completion::ToolDefinition::new(
        crate::message::ToolName::new("lookup").expect("a name"),
        "Look a word up.",
        json!({"type": "object", "properties": {}}),
    );
    let body = sent(
        &wire(CLAUDE_OPUS_4_6),
        request(GenerationOptions::default().parallel_tool_calls(false)).tool(tool.clone()),
        Mode::Unary,
    )
    .expect("parallel tool use can be turned off");
    assert_eq!(
        body["tool_choice"],
        json!({"type": "auto", "disable_parallel_tool_use": true})
    );
    let body = sent(
        &wire(CLAUDE_OPUS_4_6),
        request(GenerationOptions::default().parallel_tool_calls(false))
            .tool(tool)
            .tool_choice(ToolChoice::Required),
        Mode::Unary,
    )
    .expect("a required choice takes the flag");
    assert_eq!(
        body["tool_choice"],
        json!({"type": "any", "disable_parallel_tool_use": true})
    );
}

/// Ported from #2616 (`output_config_merges_effort_additional_params_and_the_schema_format_into_one_key`).
#[test]
fn output_config_merges_effort_additional_params_and_the_schema_format_into_one_key() {
    let wire = wire(CLAUDE_OPUS_5_5);
    let high = || GenerationOptions::default().reasoning(Effort::High);

    // The mapped effort and the schema's format share one object.
    let body = sent(&wire, request(high()).output_schema(schema()), Mode::Unary).expect("encodes");
    assert_eq!(body["output_config"]["effort"], "high");
    assert_eq!(body["output_config"]["format"]["type"], "json_schema");

    // A raw effort overrides the mapped one, and unknown keys pass through.
    let body = sent(
        &wire,
        request(high())
            .output_schema(schema())
            .additional_params(json!({
                "output_config": {"effort": "low", "task_budget": {"tokens": 1000}}
            })),
        Mode::Unary,
    )
    .expect("encodes");
    assert_eq!(body["output_config"]["effort"], "low");
    assert_eq!(body["output_config"]["task_budget"]["tokens"], 1000);
    assert_eq!(body["output_config"]["format"]["type"], "json_schema");

    // `additional_params` alone still lands once.
    let body = sent(
        &wire,
        request(GenerationOptions::default())
            .additional_params(json!({"output_config": {"effort": "max"}})),
        Mode::Unary,
    )
    .expect("encodes");
    assert_eq!(body["output_config"], json!({"effort": "max"}));

    // No setting sends no `output_config`.
    let body = sent(&wire, request(GenerationOptions::default()), Mode::Unary).expect("encodes");
    assert!(body.get("output_config").is_none(), "{body}");
}

/// Replaces #2616's `output_config_rejects_a_format_that_conflicts_with_the_output_schema`:
/// `additional_params` is above the request's own fields, so a raw format
/// merges over the schema's key by key, beside the mapped effort.
#[test]
fn a_raw_output_format_is_above_the_schemas() {
    let raw = json!({"type": "json_schema", "schema": {"additionalProperties": true}});
    let body = sent(
        &wire(CLAUDE_OPUS_5_5),
        request(GenerationOptions::default().reasoning(Effort::High))
            .output_schema(schema())
            .additional_params(json!({"output_config": {"format": raw}})),
        Mode::Unary,
    )
    .expect("encodes");
    assert_eq!(
        body["output_config"]["format"]["schema"]["additionalProperties"],
        true
    );
    assert_eq!(
        body["output_config"]["format"]["schema"]["properties"]["answer"]["type"],
        "string"
    );
    assert_eq!(body["output_config"]["effort"], "high");
}

/// Ported from #2616 (`thinking_merges_typed_defaults_with_additional_params`):
/// raw thinking keys merge into the mapped thinking, and a raw `type`
/// replaces the mapped one.
#[test]
fn thinking_merges_the_mapped_thinking_with_additional_params() {
    let wire = wire(CLAUDE_OPUS_5_5);
    let high = || GenerationOptions::default().reasoning(Effort::High);
    let body = sent(
        &wire,
        request(high()).additional_params(json!({
            "thinking": {
                "display": "summarized",
                "block_binding": {"prefix_mismatch_behavior": "error"}
            }
        })),
        Mode::Unary,
    )
    .expect("encodes");
    assert_eq!(
        body["thinking"],
        json!({
            "type": "adaptive",
            "display": "summarized",
            "block_binding": {"prefix_mismatch_behavior": "error"}
        })
    );

    let body = sent(
        &wire,
        request(high()).additional_params(json!({"thinking": {"type": "disabled"}})),
        Mode::Unary,
    )
    .expect("encodes");
    assert_eq!(body["thinking"], json!({"type": "disabled"}));
}

/// Ported from #1480 (`adaptive_parameters_merge_schema_effort_tools_and_passthrough`).
#[test]
fn adaptive_parameters_merge_schema_effort_tools_and_passthrough() {
    let body = sent(
        &wire(CLAUDE_SONNET_4_6),
        request(GenerationOptions::default().reasoning(Effort::Max))
            .output_schema(schema())
            .additional_params(json!({
                "thinking": {"display": "omitted"},
                "output_config": {"custom_option": true},
                "tools": [{"type": "web_search_20250305", "name": "web_search"}],
                "metadata": {"user_id": "test-only"}
            })),
        Mode::Unary,
    )
    .expect("encodes");
    assert_eq!(
        body["thinking"],
        json!({"type": "adaptive", "display": "omitted"})
    );
    assert_eq!(body["output_config"]["effort"], "max");
    assert_eq!(body["output_config"]["custom_option"], true);
    assert_eq!(body["output_config"]["format"]["schema"]["type"], "object");
    assert_eq!(body["tools"].as_array().map(Vec::len), Some(1));
    assert_eq!(body["metadata"]["user_id"], "test-only");
}

/// Ported from #1480 (`streaming_adaptive_effort_and_schema_share_blocking_conversion`).
#[test]
fn a_streamed_body_is_the_unary_one_with_stream_set() {
    let wire = wire(CLAUDE_OPUS_4_8);
    let request = || {
        request(GenerationOptions::default().reasoning(Effort::High))
            .output_schema(schema())
            .additional_params(json!({"metadata": {"user_id": "test-only"}}))
    };
    let streamed = sent(&wire, request(), Mode::Streaming).expect("encodes");
    let mut unary = sent(&wire, request(), Mode::Unary).expect("encodes");
    unary["stream"] = json!(true);
    assert_eq!(streamed, unary);
    assert_eq!(
        streamed["output_config"]["format"]["schema"]["type"],
        "object"
    );
}

/// Replaces #2616's `gateways_pass_thinking_and_effort_through_unchecked`:
/// a gateway refuses a reasoning option no vendor page or recording
/// confirms, and passes raw thinking and effort through unchecked.
#[test]
fn gateways_refuse_unverified_reasoning_and_pass_raw_keys_through() {
    use crate::providers::anthropic::wire::ZAI;
    let zai = gateway(&ZAI, "glm-5");
    assert_eq!(
        refused(sent(
            &zai,
            request(GenerationOptions::default().reasoning(Effort::High)),
            Mode::Unary
        )),
        "reasoning"
    );
    let body = sent(
        &zai,
        request(GenerationOptions::default()).additional_params(json!({
            "thinking": {"type": "enabled"},
            "output_config": {"effort": "turbo"}
        })),
        Mode::Unary,
    )
    .expect("a gateway passes raw keys through");
    assert_eq!(body["thinking"], json!({"type": "enabled"}));
    assert_eq!(body["output_config"]["effort"], "turbo");
}

#[test]
fn minimax_places_block_markers_for_a_short_cache() {
    use crate::providers::anthropic::wire::MINIMAX;
    let minimax = gateway(&MINIMAX, "MiniMax-M2.7");
    let body = sent(
        &minimax,
        CompletionRequest::new("hi")
            .preamble("Be brief.")
            .max_tokens(64)
            .cache(CacheRetention::Short),
        Mode::Unary,
    )
    .expect("encodes");
    assert!(body.get("cache_control").is_none(), "{body}");
    assert_eq!(
        body["system"][0]["cache_control"],
        json!({"type": "ephemeral"})
    );
    assert_eq!(
        body["messages"][0]["content"][0]["cache_control"],
        json!({"type": "ephemeral"})
    );
    assert_eq!(
        refused(sent(
            &minimax,
            request(GenerationOptions::default().cache(CacheRetention::Long)),
            Mode::Unary
        )),
        "cache"
    );
}

#[test]
fn a_cache_none_is_refused_when_the_wire_places_markers() {
    let placing = wire(CLAUDE_OPUS_4_6).with_prompt_caching();
    assert_eq!(
        refused(sent(
            &placing,
            request(GenerationOptions::default().cache(CacheRetention::None)),
            Mode::Unary
        )),
        "cache"
    );
    let body = sent(
        &wire(CLAUDE_OPUS_4_6),
        request(GenerationOptions::default().cache(CacheRetention::None)),
        Mode::Unary,
    )
    .expect("no marker is the default");
    assert!(body.get("cache_control").is_none(), "{body}");

    // Under `Ignore` a refused option is skipped with a warning.
    let body = sent(
        &placing,
        request(
            GenerationOptions::default()
                .cache(CacheRetention::None)
                .on_unsupported(OnUnsupported::Ignore),
        ),
        Mode::Unary,
    )
    .expect("skipped");
    assert!(body.get("cache_control").is_none(), "{body}");
}

/// Tools that only arrive through `additional_params.tools` still count:
/// `parallel_tool_calls(false)` sets the flag rather than being dropped.
#[test]
fn raw_tools_count_for_parallel_tool_calls() {
    let raw =
        json!({"tools": [{"name": "t", "description": "d", "input_schema": {"type": "object"}}]});
    let body = sent(
        &wire(CLAUDE_OPUS_4_6),
        request(GenerationOptions::default().parallel_tool_calls(false))
            .additional_params(raw.clone()),
        Mode::Unary,
    )
    .expect("raw tools can be called in parallel");
    assert_eq!(
        body["tool_choice"],
        json!({"type": "auto", "disable_parallel_tool_use": true})
    );
    assert_eq!(body["tools"].as_array().map(Vec::len), Some(1));

    let body = sent(
        &gateway(&XIAOMIMIMO, "mimo-v2-flash"),
        request(GenerationOptions::default().parallel_tool_calls(false)).additional_params(raw),
        Mode::Unary,
    )
    .expect("MiMo takes the flag for raw tools too");
    assert_eq!(
        body["tool_choice"],
        json!({"type": "auto", "disable_parallel_tool_use": true})
    );
}