Skip to content

feat: LFM2 tool-call normalizer --> fixes #72 (1/10 to 10/10 benchmark)#82

Open
Pshyam17 wants to merge 1 commit intoLiquid4All:mainfrom
Pshyam17:add-lfm2-tool-normalizer
Open

feat: LFM2 tool-call normalizer --> fixes #72 (1/10 to 10/10 benchmark)#82
Pshyam17 wants to merge 1 commit intoLiquid4All:mainfrom
Pshyam17:add-lfm2-tool-normalizer

Conversation

@Pshyam17
Copy link
Copy Markdown

@Pshyam17 Pshyam17 commented Apr 2, 2026

Problem

LFM2/LFM2.5 emits tool calls in three inconsistent formats depending
on context (Pythonic by default, JSON with a prompt hint, XML in some
Ollama/OpenCode setups). No agentic framework handles all three, forcing
users to write custom proxies.

What this adds

  • lfm2_tool_normalizer.py — parses all three formats into a clean
    OpenAI-compatible ToolCall dataclass
  • lfm2_agent_loop.py — drop-in agentic loop compatible with plain
    Python callables, LangChain BaseTool, and smolagents Tool
  • benchmark.py — before/after comparison across 10 format variants
  • quick_start.py — minimal working example

Benchmark

Condition Success rate
Baseline (naive JSON parse) 1/10
With LFMToolNormalizer 10/10

Notes

Complementary to the home assistant example. This normalizer targets
users running Ollama, OpenCode, or direct HuggingFace inference where
llama.cpp is not in the stack.

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