Skip to content

Add Olmo3 tool parser#1271

Open
anthonyhchan wants to merge 1 commit into
ml-explore:mainfrom
anthonyhchan:olmo3-tool-call
Open

Add Olmo3 tool parser#1271
anthonyhchan wants to merge 1 commit into
ml-explore:mainfrom
anthonyhchan:olmo3-tool-call

Conversation

@anthonyhchan
Copy link
Copy Markdown

Summary

  • Adds a tool-call parser for Olmo 3 models (e.g.
    mlx-community/Olmo-3-7B-Instruct-4bit), which emit calls as
    <function_calls>name(arg=value, ...)</function_calls> with newline-separated
    multiple calls and JSON literals (null / true / false) for argument values.
  • Wires auto-detection: _infer_tool_parser selects "olmo3" when the chat
    template contains <function_calls>

Implementation notes

  • mlx_lm/tool_parsers/olmo3.py mirrors pythonic.py. Differences:
    • No surrounding [ ] brackets on each call.
    • Per-line matching (re.MULTILINE, no DOTALL) so multiple calls on
      separate lines are parsed independently and returned as a list.
    • _coerce translates null / true / false before falling back to
      ast.literal_eval, since Olmo 3 emits JSON literals rather than Python ones.

Test plan

  • python -m pytest tests/test_tool_parsing.py -v — all 6 tests / 24 subtests pass.
  • load(Path(".../Olmo-3-7B-Instruct-4bit")) returns a wrapper with
    tool_call_start == "<function_calls>", tool_call_end == "</function_calls>",
    and a non-None tool_parser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant