Using the Kimi K2 family in agentic workflows
Always set max_tokens
Models in the Kimi K2 family can produce very long reasoning traces before arriving at a final answer. In agentic workflows where output is parsed and passed to downstream steps, always set max_tokens explicitly:
| Output type | Suggested max_tokens |
|---|---|
| Tool call responses | 256–512 |
| Short text | 512–1024 |
| Structured JSON | 1024–2048 |
| Long-form reasoning | 4096+ |
Tool schema design
Kimi K2 family models perform best when tools have clearly distinct names, descriptions, and parameter schemas. When tools have overlapping surface areas the model may select the wrong one.- Name tools by their primary action, not their domain (
read_filenotfile_tool). - Write descriptions that distinguish tools from each other, including what each tool is not for.
- Avoid optional parameters that make two tools look identical with only a flag difference.