tool_call_markers.h¶
src/inference/tool_call_markers.h
@file tool_call_markers.h @brief gh#103 (v2.8.2): family-aware tool-call CLOSE markers, derived from the resolved common_chat format.
Owners: @tvanfossen
append_sequential_stop
void entropic::append_sequential_stop(GenerationParams ¶ms, const std::string &marker)
Append a tool-call close marker to params.stop for sequential mode.
src/inference/tool_call_markers.h:93
Source · 8 lines
inline void append_sequential_stop(GenerationParams& params,
const std::string& marker) {
if (params.tool_call_mode != "sequential" || marker.empty()) { return; }
if (std::find(params.stop.begin(), params.stop.end(), marker)
== params.stop.end()) {
params.stop.push_back(marker);
}
}Activity · 4 steps
Requirements
close_marker_for_format
std::string entropic::close_marker_for_format(common_chat_format fmt)
Map a resolved common_chat format to its single-tool-call close marker.
src/inference/tool_call_markers.h:52
Source · 25 lines
inline std::string close_marker_for_format(common_chat_format fmt) {
std::string marker;
switch (fmt) {
case COMMON_CHAT_FORMAT_PEG_NATIVE:
case COMMON_CHAT_FORMAT_PEG_SIMPLE:
marker = "</tool_call>";
break;
case COMMON_CHAT_FORMAT_PEG_GEMMA4:
// gh#103 (v2.8.2): gemma4 wraps a call as
// `<|tool_call>call:NAME{...}<tool_call|>` — the per-call CLOSE is
// `<tool_call|>` (confirmed against a live gemma4_e4b transcript +
// chat.cpp:1178). Distinct from the open `<|tool_call>`, so the
// ends-with stop check fires on the close, never the open. This is
// the family where the missing hard-stop is most severe: the
// runaway past the call defeats extraction, so the terminal
// directive registers as ZERO tool calls (gh#103 consumer report).
marker = "<tool_call|>";
break;
default:
// CONTENT_ONLY / unknown: no confirmed per-call close marker —
// return "" so no stop is injected (batch-safe).
break;
}
return marker;
}