Loading
A model replies with JSON like `{"tool": "get_weather", "args": {"city": "Leeds"}}`, but sometimes wraps it in ```json fences or returns junk. Write `parse_tool_call(text, allowed)` that returns `(tool, args)` when the JSON is valid, `tool` is in the `allowed` list and `args` is a dict. Otherwise return `None`.
Strip the fences with text.strip().removeprefix("```json").removesuffix("```"), then json.loads inside try/except.