Skip to main content

trusty_code/llm/tool_call_extractor/
mod.rs

1//! Cross-provider tool-call extraction, validation, and bounded repair (#1023).
2//!
3//! Why: `ChatResponse::first_tool_calls` (see `llm::response`) only recovers a
4//! tool call when the provider populated the native
5//! `choices[0].message.tool_calls` wire field. Several model families routed
6//! through OpenRouter (Qwen, DeepSeek, Gemma, and any future non-native
7//! family — see `provider::traits::Provider::supports_native_tools`) instead
8//! emit their intended call as text inside `content`, using one of a few
9//! conventions. Before #1023 there was no fallback: `agent_loop::parse_args`
10//! silently degraded any unparseable native `arguments` string to `{}`,
11//! discarding the model's intent and dispatching the tool with no arguments
12//! at all. This module recovers the call across all four representations,
13//! validates its arguments against the tool's real schema (the same
14//! validation for every provider — `schema::validate_args`), and drives a
15//! bounded corrective-retry loop (`repair::extract_with_repair`) when the
16//! first attempt fails.
17//! What: Re-exports [`ExtractedToolCall`], [`ExtractionStrategy`],
18//! [`ToolCallExtractError`], [`ToolCallExtractor`], and the `repair` module's
19//! [`repair::extract_with_repair`] / [`repair::DEFAULT_MAX_REPAIR_ATTEMPTS`].
20//! [`ToolCallExtractor::extract`] is the single-attempt entry point: try
21//! native first, then the fallback strategies in [`strategy_order_for`]'s
22//! per-model order, then validate whatever was found against the schema
23//! looked up for that tool's name.
24//!
25//! ## Per-model strategy matrix
26//!
27//! | Model family (slug substring) | Native tools? | Fallback order (when native absent) |
28//! |---|---|---|
29//! | `claude-`, `gpt-`, `gemini-` (native families, see `provider::openrouter`) | yes | n/a — native `tool_calls` is authoritative |
30//! | `qwen`, `deepseek` | no | `<tool_call>` tag → fenced ```json → tolerant scan |
31//! | `gemma`, everything else | no | fenced ```json → `<tool_call>` tag → tolerant scan |
32//!
33//! Rationale: Qwen's and DeepSeek's published chat templates natively teach
34//! the `<tool_call>{...}</tool_call>` convention, so it is tried first for
35//! those slugs. Gemma has no standard function-calling convention; a fenced
36//! JSON block is the most common prompt-guided pattern across
37//! OpenRouter-hosted community fine-tunes, so it leads for the catch-all
38//! branch. The tolerant balanced-JSON scan is always last — it is the most
39//! expensive and least precise, only used when both structured conventions
40//! fail.
41//! Test: `tool_call_extractor::tests::*`, `strategies::tests::*`,
42//! `schema::tests::*`, `repair::tests::*`.
43
44mod error;
45mod repair;
46mod schema;
47mod strategies;
48
49pub use error::ToolCallExtractError;
50pub use repair::{DEFAULT_MAX_REPAIR_ATTEMPTS, extract_with_repair};
51pub use schema::SchemaViolation;
52
53use serde_json::Value;
54
55use crate::llm::ChatResponse;
56
57/// Synthetic call ID assigned to a tool call recovered via a text fallback
58/// strategy, since none of those conventions carry a wire-level call ID.
59const FALLBACK_CALL_ID: &str = "fallback-call-0";
60
61/// Schema-lookup callback type: tool name -> its raw OpenAI-function schema.
62///
63/// Why: `clippy::type_complexity` flags the inline `Box<dyn Fn(...) -> ...>`
64/// form; naming it here also documents the expected shape at the point
65/// `ToolCallExtractor` is defined.
66/// What: See [`ToolCallExtractor::new`] for the expected schema shape.
67type SchemaLookup<'a> = Box<dyn Fn(&str) -> Option<Value> + Send + Sync + 'a>;
68
69/// Which extraction convention recovered a tool call.
70///
71/// Why: Callers (repair-message building, logging, the per-model ordering
72/// table) need to know which strategy succeeded or was attempted.
73/// What: `Native` is the OpenAI-wire `tool_calls` field; the other three are
74/// the text-based fallbacks in `strategies`.
75/// Test: `tests::extract_native_success`, `tests::extract_fenced_json_success`,
76/// `tests::extract_angle_bracket_success`.
77#[derive(Debug, Clone, Copy, PartialEq, Eq)]
78pub enum ExtractionStrategy {
79    /// Recovered from `choices[0].message.tool_calls`.
80    Native,
81    /// Recovered from a ```` ```json ``` ```` fenced code block.
82    FencedJson,
83    /// Recovered from an `<tool_call>{...}</tool_call>` tag.
84    AngleBracket,
85    /// Recovered via the tolerant balanced-`{}`-scan last resort.
86    BalancedJsonScan,
87}
88
89/// A tool call recovered by [`ToolCallExtractor::extract`], normalised across
90/// every extraction strategy and already schema-validated.
91///
92/// Why: Downstream dispatch (`tools::ToolRegistry::dispatch_gated`) wants a
93/// single shape regardless of which strategy produced the call.
94/// What: `id` is the wire call ID for `Native`, or [`FALLBACK_CALL_ID`] for
95/// any text-based strategy (documented there — those conventions carry no
96/// ID). `arguments` is already a parsed, schema-valid `Value`.
97/// Test: `tests::extract_native_success` and friends assert every field.
98#[derive(Debug, Clone, PartialEq)]
99pub struct ExtractedToolCall {
100    /// Call ID to echo back in the subsequent `tool` result message.
101    pub id: String,
102    /// The tool's registered name.
103    pub name: String,
104    /// Parsed, schema-validated argument object.
105    pub arguments: Value,
106    /// Which strategy recovered this call.
107    pub strategy: ExtractionStrategy,
108}
109
110/// Per-model fallback strategy order, tried when no native tool call is present.
111///
112/// Why: Centralising the per-family order here (rather than scattering
113/// `if slug.contains(...)` checks through `extract`) keeps the matrix
114/// documented in exactly one place — see the module-level table above.
115/// What: Returns the three text-based strategies in priority order for
116/// `model_slug`. Matching is case-insensitive and substring-based, mirroring
117/// `provider::openrouter::slug_supports_native_tools`.
118/// Test: `tests::strategy_order_prefers_angle_bracket_for_qwen_and_deepseek`,
119/// `tests::strategy_order_prefers_fenced_json_for_others`.
120pub fn strategy_order_for(model_slug: &str) -> [ExtractionStrategy; 3] {
121    let lower = model_slug.to_ascii_lowercase();
122    if lower.contains("qwen") || lower.contains("deepseek") {
123        [
124            ExtractionStrategy::AngleBracket,
125            ExtractionStrategy::FencedJson,
126            ExtractionStrategy::BalancedJsonScan,
127        ]
128    } else {
129        [
130            ExtractionStrategy::FencedJson,
131            ExtractionStrategy::AngleBracket,
132            ExtractionStrategy::BalancedJsonScan,
133        ]
134    }
135}
136
137/// Recovers and validates tool calls across every supported provider convention.
138///
139/// Why: Bundles the schema-lookup callback so a single instance can be reused
140/// across every attempt of a [`repair::extract_with_repair`] loop without
141/// re-threading the tool registry through each call.
142/// What: Holds a boxed closure from tool name to that tool's raw
143/// OpenAI-function schema `Value` (see `tools::traits::ToolExecutor::schema`;
144/// callers typically pass a closure over `ToolRegistry::schemas()` results
145/// keyed by name). [`Self::extract`] is the single-attempt entry point.
146/// Test: `tests::*`.
147pub struct ToolCallExtractor<'a> {
148    schema_lookup: SchemaLookup<'a>,
149}
150
151impl<'a> ToolCallExtractor<'a> {
152    /// Build an extractor bound to a schema-lookup callback.
153    ///
154    /// Why: Decouples this module from `tools::ToolRegistry` directly, so it
155    /// can be unit-tested with a plain closure/`HashMap` lookup.
156    /// What: Stores `schema_lookup`; each tool's schema is expected to be the
157    /// full `{"type":"function","function":{"name","parameters",...}}`
158    /// envelope — [`Self::extract`] reads `.function.parameters` out of it.
159    /// Test: `tests::*` all construct via this constructor.
160    pub fn new(schema_lookup: impl Fn(&str) -> Option<Value> + Send + Sync + 'a) -> Self {
161        Self {
162            schema_lookup: Box::new(schema_lookup),
163        }
164    }
165
166    /// Attempt one extraction across native + fallback strategies, then validate.
167    ///
168    /// Why: This is the "single attempt" the bounded repair loop iterates:
169    /// try native first (authoritative when present), else each fallback
170    /// strategy for `model_slug` in order, then validate whatever candidate
171    /// was found against its tool's schema.
172    /// What: If `response.first_tool_calls()` is non-empty, parses and
173    /// validates each as [`ExtractionStrategy::Native`], returning the first
174    /// failure encountered (or all calls on full success). Otherwise scans
175    /// `response.first_text()` via [`strategy_order_for`]'s fallback order,
176    /// stopping at the first strategy that recovers a candidate — even if
177    /// that candidate then fails validation, later strategies are NOT tried
178    /// (the model committed to a shape; the repair loop, not a different
179    /// parse strategy, is the correct next step).
180    /// Test: `tests::extract_native_success`, `tests::extract_fenced_json_success`,
181    /// `tests::extract_angle_bracket_success`, `tests::extract_no_call_found`,
182    /// `tests::extract_native_malformed_arguments`,
183    /// `tests::extract_schema_invalid_arguments`, `tests::extract_unknown_tool`.
184    pub fn extract(
185        &self,
186        response: &ChatResponse,
187        model_slug: &str,
188    ) -> Result<Vec<ExtractedToolCall>, ToolCallExtractError> {
189        let native = response.first_tool_calls();
190        if !native.is_empty() {
191            let mut out = Vec::with_capacity(native.len());
192            for call in native {
193                let args =
194                    self.parse_and_validate(&call.function.name, &call.function.arguments)?;
195                out.push(ExtractedToolCall {
196                    id: call.id.clone(),
197                    name: call.function.name.clone(),
198                    arguments: args,
199                    strategy: ExtractionStrategy::Native,
200                });
201            }
202            return Ok(out);
203        }
204
205        let text = response.first_text().unwrap_or_default();
206        let order = strategy_order_for(model_slug);
207        for strategy in order {
208            let candidate = match strategy {
209                ExtractionStrategy::FencedJson => strategies::extract_fenced_json(&text),
210                ExtractionStrategy::AngleBracket => strategies::extract_angle_bracket(&text),
211                ExtractionStrategy::BalancedJsonScan => {
212                    strategies::extract_balanced_json_scan(&text)
213                }
214                ExtractionStrategy::Native => {
215                    unreachable!("strategy_order_for never returns Native")
216                }
217            };
218            if let Some((name, args)) = candidate {
219                let validated = self.validate(&name, args, strategy)?;
220                return Ok(vec![ExtractedToolCall {
221                    id: FALLBACK_CALL_ID.to_string(),
222                    ..validated
223                }]);
224            }
225        }
226
227        Err(ToolCallExtractError::NoCallFound {
228            tried: order.to_vec(),
229        })
230    }
231
232    /// Parse a raw JSON arguments string and validate it against `name`'s schema.
233    ///
234    /// Why: This is the exact per-call operation `Self::extract`'s native
235    /// branch needs, factored out so a caller that already has a single known
236    /// `(name, raw_arguments)` pair — notably `agent_loop::dispatch_all`,
237    /// which dispatches native `ToolCall`s one at a time — can validate
238    /// without constructing a `ChatResponse`. This is the #1023 replacement
239    /// for the pre-#1023 `agent_loop::parse_args`, which silently degraded
240    /// any unparseable `arguments` string to `{}`; a genuine JSON syntax
241    /// error now surfaces as a structured, actionable
242    /// [`ToolCallExtractError::MalformedArguments`] instead.
243    /// What: An empty or all-whitespace `raw_arguments` is treated as `{}`
244    /// (many providers send an empty string for a zero-argument call — this
245    /// preserves that legacy leniency) and still runs through schema
246    /// validation, so a tool with required arguments correctly reports
247    /// `SchemaInvalid` rather than silently succeeding. A non-empty string
248    /// that fails to parse reports `MalformedArguments`. Returns the
249    /// validated `arguments` value on success.
250    /// Test: `tests::parse_and_validate_success`,
251    /// `tests::parse_and_validate_empty_string_becomes_empty_object`,
252    /// `tests::parse_and_validate_malformed_json`.
253    pub fn parse_and_validate(
254        &self,
255        name: &str,
256        raw_arguments: &str,
257    ) -> Result<Value, ToolCallExtractError> {
258        let trimmed = raw_arguments.trim();
259        let args: Value = if trimmed.is_empty() {
260            Value::Object(Default::default())
261        } else {
262            serde_json::from_str(trimmed).map_err(|source| {
263                ToolCallExtractError::MalformedArguments {
264                    name: name.to_string(),
265                    source,
266                }
267            })?
268        };
269        self.validate(name, args, ExtractionStrategy::Native)
270            .map(|c| c.arguments)
271    }
272
273    /// Validate one candidate `(name, args)` pair against its tool's schema.
274    ///
275    /// Why: Shared by both the native and fallback branches of [`Self::extract`]
276    /// so every strategy funnels through the exact same validation (#1023:
277    /// "all providers share same validation plumbing").
278    /// What: Looks up `name` via `schema_lookup`; `None` → `UnknownTool`.
279    /// Reads `schema["function"]["parameters"]` (defaulting to an empty
280    /// object schema `{}` when absent, which validates everything) and runs
281    /// `schema::validate_args`. Returns a placeholder-ID `ExtractedToolCall`
282    /// on success — callers overwrite `id` with the real value.
283    /// Test: `tests::extract_unknown_tool`, `tests::extract_schema_invalid_arguments`.
284    fn validate(
285        &self,
286        name: &str,
287        args: Value,
288        strategy: ExtractionStrategy,
289    ) -> Result<ExtractedToolCall, ToolCallExtractError> {
290        let schema =
291            (self.schema_lookup)(name).ok_or_else(|| ToolCallExtractError::UnknownTool {
292                name: name.to_string(),
293            })?;
294        let parameters = schema
295            .get("function")
296            .and_then(|f| f.get("parameters"))
297            .cloned()
298            .unwrap_or_else(|| Value::Object(Default::default()));
299
300        schema::validate_args(&parameters, &args).map_err(|violations| {
301            ToolCallExtractError::SchemaInvalid {
302                name: name.to_string(),
303                violations,
304            }
305        })?;
306
307        Ok(ExtractedToolCall {
308            id: String::new(),
309            name: name.to_string(),
310            arguments: args,
311            strategy,
312        })
313    }
314}
315
316// ── Tests ─────────────────────────────────────────────────────────────────────
317
318#[cfg(test)]
319mod tests {
320    use super::*;
321    use serde_json::json;
322
323    fn bash_schema_entry() -> Value {
324        json!({
325            "type": "function",
326            "function": {
327                "name": "bash",
328                "parameters": {
329                    "type": "object",
330                    "properties": { "command": { "type": "string" } },
331                    "required": ["command"],
332                    "additionalProperties": false
333                }
334            }
335        })
336    }
337
338    fn extractor_with_bash() -> ToolCallExtractor<'static> {
339        ToolCallExtractor::new(|name| match name {
340            "bash" => Some(bash_schema_entry()),
341            _ => None,
342        })
343    }
344
345    fn response_with_native_call(name: &str, arguments: &str) -> ChatResponse {
346        let fixture = format!(
347            r#"{{
348              "id": "gen-1",
349              "choices": [{{
350                "message": {{
351                  "role": "assistant",
352                  "content": null,
353                  "tool_calls": [{{
354                    "id": "call_1",
355                    "type": "function",
356                    "function": {{"name": "{name}", "arguments": {arguments:?}}}
357                  }}]
358                }},
359                "finish_reason": "tool_calls"
360              }}],
361              "usage": {{"prompt_tokens": 1, "completion_tokens": 1, "total_tokens": 2}}
362            }}"#
363        );
364        serde_json::from_str(&fixture).expect("fixture deserialises")
365    }
366
367    fn response_with_text(text: &str) -> ChatResponse {
368        let fixture = json!({
369            "id": "gen-2",
370            "choices": [{
371                "message": { "role": "assistant", "content": text, "tool_calls": [] },
372                "finish_reason": "stop"
373            }],
374            "usage": {"prompt_tokens": 1, "completion_tokens": 1, "total_tokens": 2}
375        });
376        serde_json::from_str(&fixture.to_string()).expect("fixture deserialises")
377    }
378
379    /// Native `tool_calls` with valid arguments extracts and validates cleanly.
380    ///
381    /// Why: The primary, cheapest path — most requests never need a fallback.
382    /// What: A response with a valid native call; assert strategy + fields.
383    /// Test: this test.
384    #[test]
385    fn extract_native_success() {
386        let resp = response_with_native_call("bash", r#"{"command": "ls"}"#);
387        let extractor = extractor_with_bash();
388        let calls = extractor
389            .extract(&resp, "anthropic/claude-sonnet-4-5")
390            .expect("extract");
391        assert_eq!(calls.len(), 1);
392        assert_eq!(calls[0].id, "call_1");
393        assert_eq!(calls[0].name, "bash");
394        assert_eq!(calls[0].arguments, json!({"command": "ls"}));
395        assert_eq!(calls[0].strategy, ExtractionStrategy::Native);
396    }
397
398    /// A fenced ```json block is recovered when no native call is present.
399    ///
400    /// Why: Required acceptance-criterion scenario for #1023.
401    /// What: A text-only response containing a fenced tool call.
402    /// Test: this test.
403    #[test]
404    fn extract_fenced_json_success() {
405        let text = "```json\n{\"name\": \"bash\", \"arguments\": {\"command\": \"pwd\"}}\n```";
406        let resp = response_with_text(text);
407        let extractor = extractor_with_bash();
408        let calls = extractor
409            .extract(&resp, "google/gemma-2-27b-it")
410            .expect("extract");
411        assert_eq!(calls[0].name, "bash");
412        assert_eq!(calls[0].strategy, ExtractionStrategy::FencedJson);
413        assert_eq!(calls[0].id, FALLBACK_CALL_ID);
414    }
415
416    /// An `<tool_call>` tag is recovered when no native call is present.
417    ///
418    /// Why: Required acceptance-criterion scenario for #1023.
419    /// What: A text-only response using the tag convention, for a Qwen slug
420    /// (which prioritises this strategy per `strategy_order_for`).
421    /// Test: this test.
422    #[test]
423    fn extract_angle_bracket_success() {
424        let text = "<tool_call>{\"name\": \"bash\", \"arguments\": {\"command\": \"echo hi\"}}</tool_call>";
425        let resp = response_with_text(text);
426        let extractor = extractor_with_bash();
427        let calls = extractor
428            .extract(&resp, "qwen/qwen-2.5-coder-32b-instruct")
429            .expect("extract");
430        assert_eq!(calls[0].name, "bash");
431        assert_eq!(calls[0].strategy, ExtractionStrategy::AngleBracket);
432    }
433
434    /// `parse_and_validate` succeeds for well-formed, schema-valid arguments.
435    ///
436    /// Why: Guards the direct per-call entry point used by
437    /// `agent_loop::dispatch_all` (the pre-#1023 `parse_args` replacement).
438    /// What: Valid JSON for `bash`; assert the parsed value.
439    /// Test: this test.
440    #[test]
441    fn parse_and_validate_success() {
442        let extractor = extractor_with_bash();
443        let args = extractor
444            .parse_and_validate("bash", r#"{"command": "ls"}"#)
445            .expect("valid");
446        assert_eq!(args, json!({"command": "ls"}));
447    }
448
449    /// An empty (or whitespace-only) arguments string is treated as `{}`.
450    ///
451    /// Why: Some providers send an empty string for a zero-argument call;
452    /// preserving this leniency avoids regressing existing behaviour. It
453    /// must still be validated — a required-field violation surfaces rather
454    /// than silently succeeding.
455    /// What: Empty string against `bash` (which requires `command`) reports
456    /// `SchemaInvalid`, not a parse error.
457    /// Test: this test.
458    #[test]
459    fn parse_and_validate_empty_string_becomes_empty_object() {
460        let extractor = extractor_with_bash();
461        let err = extractor
462            .parse_and_validate("bash", "")
463            .expect_err("missing required field");
464        assert!(matches!(err, ToolCallExtractError::SchemaInvalid { .. }));
465    }
466
467    /// A genuinely malformed (non-empty) arguments string reports `MalformedArguments`.
468    ///
469    /// Why: This is the exact #1023 regression target — previously silently
470    /// degraded to `{}` and dispatched anyway.
471    /// What: `"not json"` against `bash`.
472    /// Test: this test.
473    #[test]
474    fn parse_and_validate_malformed_json() {
475        let extractor = extractor_with_bash();
476        let err = extractor
477            .parse_and_validate("bash", "not json")
478            .expect_err("malformed");
479        assert!(
480            matches!(err, ToolCallExtractError::MalformedArguments { name, .. } if name == "bash")
481        );
482    }
483
484    /// No recognisable call anywhere yields a structured `NoCallFound`, not a panic.
485    ///
486    /// Why: The model may just answer in prose; extraction must fail cleanly.
487    /// What: Plain prose text, no native calls.
488    /// Test: this test.
489    #[test]
490    fn extract_no_call_found() {
491        let resp = response_with_text("Sure, here's the answer: 42.");
492        let extractor = extractor_with_bash();
493        let err = extractor
494            .extract(&resp, "google/gemma-2-27b-it")
495            .expect_err("should fail");
496        assert!(matches!(err, ToolCallExtractError::NoCallFound { .. }));
497    }
498
499    /// A native call with unparseable JSON arguments reports `MalformedArguments`.
500    ///
501    /// Why: This is the exact case `agent_loop::parse_args` used to silently
502    /// degrade to `{}`; #1023 requires it surface as a structured error instead.
503    /// What: Native call whose `arguments` string is invalid JSON.
504    /// Test: this test.
505    #[test]
506    fn extract_native_malformed_arguments() {
507        let resp = response_with_native_call("bash", "{not valid json");
508        let extractor = extractor_with_bash();
509        let err = extractor
510            .extract(&resp, "anthropic/claude-sonnet-4-5")
511            .expect_err("should fail");
512        assert!(
513            matches!(err, ToolCallExtractError::MalformedArguments { name, .. } if name == "bash")
514        );
515    }
516
517    /// A native call to an unregistered tool name reports `UnknownTool`.
518    ///
519    /// Why: A hallucinated tool name has no schema to validate against.
520    /// What: Call a tool absent from the extractor's schema lookup.
521    /// Test: this test.
522    #[test]
523    fn extract_unknown_tool() {
524        let resp = response_with_native_call("frobnicate", "{}");
525        let extractor = extractor_with_bash();
526        let err = extractor
527            .extract(&resp, "anthropic/claude-sonnet-4-5")
528            .expect_err("should fail");
529        assert!(matches!(err, ToolCallExtractError::UnknownTool { name } if name == "frobnicate"));
530    }
531
532    /// A native call with valid JSON but schema-invalid arguments reports `SchemaInvalid`.
533    ///
534    /// Why: Valid JSON that doesn't satisfy the tool's schema (missing
535    /// required field) is a distinct, repairable failure mode.
536    /// What: Call `bash` with no `command` field.
537    /// Test: this test.
538    #[test]
539    fn extract_schema_invalid_arguments() {
540        let resp = response_with_native_call("bash", "{}");
541        let extractor = extractor_with_bash();
542        let err = extractor
543            .extract(&resp, "anthropic/claude-sonnet-4-5")
544            .expect_err("should fail");
545        assert!(matches!(err, ToolCallExtractError::SchemaInvalid { name, .. } if name == "bash"));
546    }
547
548    /// Qwen and DeepSeek slugs prioritise the angle-bracket strategy.
549    ///
550    /// Why: Guards the documented per-model matrix stays correct as the table
551    /// evolves.
552    /// What: Assert the first element of the order for representative slugs.
553    /// Test: this test.
554    #[test]
555    fn strategy_order_prefers_angle_bracket_for_qwen_and_deepseek() {
556        for slug in ["qwen/qwen-2.5-coder-32b-instruct", "deepseek/deepseek-chat"] {
557            assert_eq!(
558                strategy_order_for(slug)[0],
559                ExtractionStrategy::AngleBracket
560            );
561        }
562    }
563
564    /// Gemma and any other non-native family prioritise fenced-JSON.
565    ///
566    /// Why: Guards the catch-all branch of the matrix.
567    /// What: Assert the first element for Gemma and an arbitrary other slug.
568    /// Test: this test.
569    #[test]
570    fn strategy_order_prefers_fenced_json_for_others() {
571        for slug in ["google/gemma-2-27b-it", "mistralai/mixtral-8x7b"] {
572            assert_eq!(strategy_order_for(slug)[0], ExtractionStrategy::FencedJson);
573        }
574    }
575}