v0.2.0 — LLM reliability + batched-round turn model #9

Merged
kamilkrzywda merged 2 commits from reliability-batched-round into master 2026-10-11 16:46:02 +02:00
Owner

v0.2.0

502 reliability fix. The live reasoning model qwen3.8-27b was exhausting its max_tokens:4000 output budget on chain-of-thought, returning null content → HTTP 502 on roughly half of turns (with no retry or logging). llm.chat now sends reasoning_effort:"low" (thinking stays active but cut ~85%), retries up to 3× with 2s→3s backoff on timeout/5xx/network/null-content (not on 4xx), logs every call, and the output budget is env-tunable (LLM_MAX_TOKENS, default 4000). Turns are now ~4–5× faster and well under the ~90s upstream proxy wall.

Batched round model. Actions and diplomatic messages are queued into game.pending via POST /api/games/:id/action and POST /api/games/:id/diplomacy (fast, no LLM call, no turn advance). A single "Jump forward" (POST /api/games/:id/jump) commits the whole batch in ONE LLM turn, applies the TurnResult, clears the queue, and advances the world by one period. Diplomacy no longer advances a turn on its own; the old POST /api/games/:id/turn route is removed.

UI. New small "Add action" / "Add to round" buttons (secondary, sm) plus a prominent "Jump forward" button (primary, shows the queued count) and a visible pending-queue list in the action panel.

Version bump 0.1.0 → 0.2.0.

Fixes #8

## v0.2.0 **502 reliability fix.** The live reasoning model `qwen3.8-27b` was exhausting its `max_tokens:4000` output budget on chain-of-thought, returning null `content` → HTTP 502 on roughly half of turns (with no retry or logging). `llm.chat` now sends `reasoning_effort:"low"` (thinking stays active but cut ~85%), retries up to 3× with 2s→3s backoff on timeout/5xx/network/null-content (not on 4xx), logs every call, and the output budget is env-tunable (`LLM_MAX_TOKENS`, default 4000). Turns are now ~4–5× faster and well under the ~90s upstream proxy wall. **Batched round model.** Actions and diplomatic messages are queued into `game.pending` via `POST /api/games/:id/action` and `POST /api/games/:id/diplomacy` (fast, no LLM call, no turn advance). A single "Jump forward" (`POST /api/games/:id/jump`) commits the whole batch in ONE LLM turn, applies the `TurnResult`, clears the queue, and advances the world by one period. Diplomacy no longer advances a turn on its own; the old `POST /api/games/:id/turn` route is removed. **UI.** New small "Add action" / "Add to round" buttons (secondary, sm) plus a prominent "Jump forward" button (primary, shows the queued count) and a visible pending-queue list in the action panel. Version bump `0.1.0` → `0.2.0`. Fixes #8
kamilkrzywda added 2 commits 2026-10-11 16:44:07 +02:00
- send top-level reasoning_effort: "low" (LLM_REASONING_EFFORT) to cut the qwen3.8-27b CoT ~85%, so content is no longer truncated to null -> the ~50% 502s
- new env: LLM_MAX_TOKENS (default 4000, per-call opts.maxTokens still overrides), LLM_REASONING_EFFORT (default "low", off/empty omits the field)
- chat() retries up to 3 attempts: timeout/abort, 5xx, network errors (ECONNRESET/ECONNREFUSED/socket closed), null/empty content; backoff 2s->3s (2000*1.5^(n-1), +/-20% jitter); 4xx throws immediately
- logging: '[llm] chat ok' {ms, finishReason} on success; '[llm] chat failed' {attempts, lastStatus, message, totalMs} on final failure
- tests: 12 in llm.test.ts (retry success/failure, no 4xx retry, null-content retry, logging spies); AGENTS.md env table + gotchas updated
kamilkrzywda scheduled this pull request to auto merge when all checks succeed 2026-10-11 16:44:12 +02:00
kamilkrzywda merged commit 502fbd4874 into master 2026-10-11 16:46:02 +02:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: OpenCode/History#9