Skip to content

Commit 0b59211

Browse files
committed
Drop response_format when sending tools
Several inference stacks (Kimi-K2 on HF Router, vLLM with some tool parsers) reject 'You cannot specify response format and function call at the same time'. The system prompt already mandates JSON-only output and _extract_json is forgiving, so dropping response_format during the tool loop is safe.
1 parent 52be01e commit 0b59211

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

reviewbot/reviewer.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,19 @@ def _run_agentic_loop(
152152
metrics = _AggregateMetrics()
153153
tools_arg = TOOL_SPECS if tool_env is not None else None
154154

155+
# Several inference stacks (Kimi-K2 on HF Router, vLLM with some
156+
# tool parsers, etc.) reject `response_format` + `tools` in the same
157+
# request. We omit response_format whenever tools are in play and
158+
# rely on the system prompt's "output ONLY a single JSON object"
159+
# instruction plus _extract_json's forgiving parsing for the final
160+
# answer.
161+
response_format = None if tools_arg else {"type": "json_object"}
162+
155163
for iteration in range(1, cfg.tool_max_iterations + 1):
156164
log.info("Agent loop iteration %d/%d", iteration, cfg.tool_max_iterations)
157165
chat = llm.complete(
158166
messages,
159-
response_format={"type": "json_object"},
167+
response_format=response_format,
160168
max_tokens=cfg.llm_max_tokens,
161169
tools=tools_arg,
162170
tool_choice="auto" if tools_arg else None,

0 commit comments

Comments
 (0)