Long thinking-heavy turns (multi-image vision extraction) legitimately
run >120s without emitting chunks; the idle TTL killed cursor-agent
mid-turn, surfacing to HTTP clients as an empty assistant turn.
- TURN_DEADLINE_MS (default 900s) applies while a prompt is in flight;
SESSION_TTL_MS (idle, 120s) applies between turns
- _touchTimer() re-arms on every session/update (chunks, thoughts)
- _finishTurn clears _promptInFlight and re-arms the idle TTL
Verified with the real 11-photo TTN replay that previously died with
'LLM stream returned empty assistant turn' after mid-turn TTL kills.
- normalizeToolChoice maps OpenAI tool_choice values to internal shapes
- required/named: prepend a mandatory-tool directive block; buffer text
deltas and only flush when a tool call actually arrives; on plain-text
turn, retry in-process with a nudge block (max 2 retries) instead of
emitting the violating text (streaming + non-streaming paths)
- none: prepend a no-tools directive
- unit tests for all new mapping/directive helpers (32 passing)
Verified live against cursor-agent ACP with model=auto: image+required
yields clean tool_calls chunks with no text pollution; follow-up turns
resolve parked MCP tool calls and retry on invalid observations.