Skip to main content
Utility functions for parsing MCP tool calls from model output.

extract_tool_calls_from_text

def extract_tool_calls_from_text(content: str):
Extract tool call dictionaries from raw text output.

_collect_tool_calls

def _collect_tool_calls(payload: Any, accumulator: List[Dict[str, Any]]):
Collect valid tool call dictionaries from parsed payloads.

_try_parse_json_like

def _try_parse_json_like(snippet: str):
Parse a JSON or JSON-like snippet into Python data.

_find_json_candidate

def _find_json_candidate(content: str, start_idx: int):
Locate a balanced JSON-like segment starting at __INLINE_CODE_0__.

_truncate_snippet

def _truncate_snippet(snippet: str, limit: int = 120):
Return a truncated representation suitable for logging.
I