Headless: max_tokens never sent on the wire; length-truncated tool calls are silently discarded (empty output, no error) #3685
Replies: 1 comment
|
Verified the chain in rc.8 ( The harness side does forward the value (when configured per-model)
So for a properly configured per-model The omission is inside pi-ai's openai-completions wire layerThe wire field spelling is governed by pi-ai's
Zero-code disambiguationSet The silent no-op is by-design turn-end, but invisible
Happy to provide the exact request-config trace with line numbers if useful; the event trace you offered would confirm which mechanism (1 vs 2) holds. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Version: 0.1.0-rc.7 (npm), headless profile, custom openai-completions provider (local mlx_vlm server).
Setup: Provider/model config sets maxTokens: 32768 and contextWindow: 262144, and the session's request/header event shows those values. However, the actual HTTP request contains no max_tokens field, so the server applies its own default completion cap (mlx_vlm: 2048 tokens).
What happens: Any assistant response longer than the server default - e.g. a write tool call for a 300+ line file - is truncated by the server with finish_reason: length. dsh records stopReason: length, drops the incomplete tool call, and ends the turn: the final assistant/message has empty content, stdout is empty, exit code 0. Nothing is written to disk and no error is surfaced. In agentic use this presents as "claimed done / silent no-op" on large file writes.
Repro: Point a headless profile at any OpenAI-compatible server with a default completion cap, then ask dsh to write a single file of 300+ unique lines supplied in the prompt. Observe empty output and no file. Raising the cap server-side (e.g. MLX_VLM_MAX_TOKENS=32768 for mlx_vlm) fully resolves it, confirming the cause.
Expected: (1) send the configured maxTokens as max_tokens in the request; (2) when a response ends with stopReason: length mid-tool-call, surface an error (or retry/continue) instead of silently discarding the turn.
The max_tokens fix was deliberately NOT in dsh at all: since dsh omits max_tokens from its API requests (its own config is client-side only), we raised the server's default cap instead - MLX_VLM_MAX_TOKENS=32768 as an env var in start-brain.sh - so any client that omits the field now gets a 32K ceiling instead of mlx_vlm's hidden 2048, which is what had been decapitating large tool calls.
Happy to provide the session .jsonl.zstd event trace.
All reactions