1
0
Fork 0
polaris-task-force/docs
Z8MB1E 51ead07da0 fix(ai): drive the structured stream and use the chat endpoint
Dialogue drafting hung on "Drafting..." forever against OpenRouter, with the
provider having received and completed the request. Two independent faults, both
found by running the app's own code against the live endpoint.

The hang: streamObject is lazy. Awaiting result.object alone does not pump the
stream in this SDK version, so the promise waited for a parse that never started
and the call sat until its ten minute ceiling. One identical request, measured
twice: object-only never returned in 60s, draining textStream first returned a
valid draft in 6.9s. generateStructured now drains the stream before reading the
object.

The endpoint: provider(modelId) resolves to OpenAI's Responses API, which only
OpenAI implements. OpenRouter answered 200 and never completed. Every
OpenAI-compatible service the app targets serves /chat/completions, which the
plain path already used, so chatModelFor reaches the model through .chat(). The
instrumented request now goes to /chat/completions and Compose's structured
branch uses the same call.

Defences, since a provider can still answer and then go quiet: an idle watchdog
aborts a body that delivers no bytes for 60s on both paths, transport retries are
off so one stall is one wait, a draft is capped at four minutes, and the dialog
has a UI watchdog plus a catch that shows the failure instead of spinning.

Against the live endpoint the real function now returns a five node draft in
6.2s. 246 tests across 24 files pass, including a regression test that fails if
the stream drain is ever removed.
2026-12-01 01:47:49 -05:00
..
.logs docs(deployment): update deployment diagram for clarity and add subtask log 2026-08-14 21:21:16 -04:00
arma-bridge feat(lockers): seed and unlimited-stock sync for limited arsenal 2026-11-20 19:52:15 -05:00
backups/pre-agents-split-20261009 docs(agents): split domain guidance into nested AGENTS.md files 2026-10-09 15:46:36 -04:00
bot feat(evaluations): gate leadership ratings by rank instead of squad assignments 2026-10-25 02:53:49 -04:00
case-studies docs: add AGENTS.md subdirectories and login case study 2026-08-19 19:48:35 -04:00
economy feat(economy): add economy tick with demand simulation and price modifiers 2026-09-06 17:22:30 -04:00
operations chore(operations): rollout controls, reconciliation, and bridge recovery 2026-09-20 02:45:00 -04:00
ai-settings.md fix(ai): drive the structured stream and use the chat endpoint 2026-12-01 01:47:49 -05:00
map-system.md feat(map-objectives): superuser-authored strategic objectives on mission maps 2026-10-27 02:12:31 -04:00
npc-dialogue-ai.md docs(npc-dialogue): sync the contract with the start-node exception 2026-11-24 15:05:19 -05:00
operation-timeline.md docs: add POLARIS operations timeline with campaign spine and branch stubs 2026-11-22 18:44:10 -05:00
wiki-demo-article.md docs(wiki): reword demo article examples 2026-09-06 17:23:03 -04:00
wiki-infobox-template.md feat(wiki): add scoped template CSS and developer HTML templates 2026-09-06 05:32:48 -04:00