Commit Graph
1 Commits
Author SHA1 Message Date
Benjiyaya 447a4802c9 fix(agent): generate story beats and script scenes in chunks
Long-form generation asked the LLM for the whole board in one response —
a 50-beat story or 20-scene script is a multi-thousand-token JSON answer
that small/local models take minutes to stream, often under-deliver, and
then a single short chunk retried the ENTIRE thing. That is the "Draft
Storyline / Regenerate Script hangs" bug.

Both generators now write incrementally:
- Script: SCRIPT_CHUNK (4) scenes per call, each fed the full context plus
  the last two written scenes for continuity.
- Story: STORY_CHUNK (12) beats per call — a brief call (title, logline,
  cast, opening beats) then continuations given the established cast and
  recent beats.

Both renumber order_index gaplessly, retry only a short chunk, publish
agent.thinking progress per chunk, and keep single-call behavior for small
boards. The generate_story/generate_script agent tools route through the
same code, so the agent loop benefits too.
2026-09-06 16:07:10 +08:00