Skip to content

Local AI: cap Ollama output tokens and type its timeouts - #94

Merged
MarcusJRLee merged 2 commits into
mainfrom
roadmap/local_ai_refinement_latency
Nov 17, 2026
Merged

MarcusJRLee merged 2 commits into
mainfrom
roadmap/local_ai_refinement_latency

Conversation

@MarcusJRLee

Copy link
Copy Markdown
Owner

Summary

  • Root cause: requests to Ollama had no num_predict. Ollama's default is to generate with no limit, shifting its context as it goes, so a repetition loop ran until the 15 s transport timeout. The Apple refiner already capped its output.
  • Both providers now share LocalAIOutputTokenBudget (min(2048, max(128, chars/2 + 128))). Ollama sends it as num_predict.
  • done_reason: "length" → new typed outputLimitReached. URLError.timedOut → typed timedOut. The two refinement-timeout messages no longer say "three-second".
  • The response carries prompt token count and prompt time.
  • The evaluation harness runs 6 corpus rounds (114 warm samples) and 20 cold samples, and records per-outcome token counts.
  • Retires local_ai_refinement_latency to an Ideas row, at Ser's direction. The game-plan row stays Open: nothing is re-measured, because no model downloads were approved and qwen3.5:4b isn't installed.
Criterion Download qwen3.5:4b and measure Land cap unmeasured Drop the item
Bounds runaway generation 🟢 Fixed and proven 🟢 Fixed; contract checked live 🔴 Still 15 s
Meets Ser's no-download decision 🔴 3.39 GB pull 🟢 No download 🟢 No download
Docs honesty 🟢 Measured 🟢 Marked unmeasured 🟡 Row stays stale
Future measurement ready 🟢 🟢 Harness kept 🔴

Recommendation: land unmeasured, per Ser.

Verification

  • scripts/check.sh and scripts/check_ios.sh pass (host load ~6).
  • New tests:
    • a fake model looping until num_predict ends as outputLimitReached;
    • a transport timeout becomes timedOut;
    • requests carry the budget.
  • Live loopback check on Ollama 0.40.4 with the installed qwen2.5-coder: num_predict: 136 returned done_reason: "length" and eval_count: 136 in 1.98 s, with truncated JSON (which becomes outputLimitReached).
  • Not measured: Qwen 3.5 latency (no model). Not driven: spoken Local AI Dictation (no speech input in this session).

🤖 Generated with Claude Code

MarcusJRLee and others added 2 commits November 16, 2026 20:30
Ollama requests carried no num_predict, so a repetition loop generated until
the 15-second transport timeout. Every provider now shares one output budget;
reaching it is outputLimitReached, and a transport timeout is timedOut. The
evaluation runs six corpus rounds (114 warm samples) and 20 cold samples.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…unmeasured cap

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MarcusJRLee
MarcusJRLee merged commit 670ef4f into main Nov 17, 2026
8 checks passed
@MarcusJRLee
MarcusJRLee deleted the roadmap/local_ai_refinement_latency branch November 17, 2026 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant