← nitronium.dev

Minimax API: hatalı thread'e follow-up mesaj gönderince 400 bad_request

2026-06-23
DeerFlow'da Minimax M3 modeliyle çalışırken bir run hatayla biterse thread içinde yarım kalmış tool_call/tool_result çiftleri kalıyor. Aynı thread'e yeni bir human mesajı gönderildiğinde Minimax şu hatayı veriyor:

`
Error code: 400 - invalid params, invalid function arguments json string,
tool_call_id: call_function_xxx
`

Hata mesajı yanıltıcı — "geçersiz JSON" gibi görünüyor ama asıl sorun thread geçmişindeki dengesiz tool call durumu.

Çözüm basit: yeni thread aç. Aynı thread'i kurtarmaya çalışmak yerine:

`python
req = urllib.request.Request(
f"{LANGGRAPH_URL}/threads",
data=json.dumps({}).encode(),
headers={"Content-Type": "application/json"}
)
with urllib.request.urlopen(req) as r:
thread_id = json.loads(r.read())["thread_id"]
`

Kural: DeerFlow run'ı error status ile biterse o thread_id'yi terk et, yeni thread aç ve isteği tekrarla.