[Bugfix][Frontend] Fix Inkling tool name leaking into content after reasoning (#58792)

Signed-off-by: Baljinder Hothi <baljinder.hothi@cohere.com>
Co-authored-by: Flora Feng <4florafeng@gmail.com>
This commit is contained in:
Baljinder Hothi
2026-09-26 00:38:52 +00:00
committed by GitHub
co-authored by Flora Feng
parent da1aaec31f
commit fdcce47e9b
2 changed files with 38 additions and 3 deletions
+4 -3
View File
@@ -167,11 +167,12 @@ def inkling_config() -> ParserEngineConfig:
(EventType.REASONING_END, EventType.TOOL_CALL_START),
),
}
# Block-end terminals behave identically regardless of label. A
# closed tool block returns to CONTENT (Inkling has no section wrapper;
# A closed tool block returns to CONTENT (Inkling has no section wrapper;
# blocks of any kind may follow), which also keeps the block-kind
# and role tokens out of the engine's tool-terminal set so the
# skip_tool_parsing reasoning pass still classifies reasoning.
# In a reasoning block, THINK_END defers REASONING_END to the next block
# opener so the function-name header is not emitted as content.
for end in ("THINK_END", "END_SAMPLING"):
transitions[(ParserState.CONTENT, end)] = Transition(
ParserState.CONTENT,
@@ -179,7 +180,7 @@ def inkling_config() -> ParserEngineConfig:
)
transitions[(ParserState.REASONING, end)] = Transition(
ParserState.CONTENT,
(EventType.REASONING_END,),
() if end == "THINK_END" else (EventType.REASONING_END,),
)
transitions[(ParserState.TOOL_ARGS, end)] = Transition(
ParserState.CONTENT,