five-on-it / apps/creator/src/runner
apps/creator/src/runner
One creation, run (TECHNICAL_SPECS §9.8): the loop of a model's turns over the creation's tools (tools.ts, the MCP server in this process as the job's own session), from the brief to a game that builds without an error, within the job's caps: LIMITS (the model's calls, its tokens in and out, the most it answers with) and the API's (caps: what it may spend, its builds, its minutes). It stops when the same errors come back from two builds in a row, when the model stops talking before a build passed (both the brief's fault: the creation stays spent), and when the model's provider or the API cannot be reached (no fault of the brief: system, the creation given back).
Every few seconds, and at each step, a heartbeat tells the API what the job is doing and what it spent; one that says stop (the job was cancelled) aborts the model's turn under way, as does the API refusing the session (401: the job's grant revoked). At each change of step the history is pruned: the long answers of the tools of the steps before the last are cut to a few lines (the cached prefix, the card and the tools, stays as it is).
Before each call, a model with a price (OpenRouter's, read at start) is bounded: the conversation's tokens read at most (a token for every three characters) and the most it may answer must fit what is left of the job's dollars, so its answer is cut shorter, or the job stops before a call that could pass its cap. Its outcome carries its transcript (the conversation after the system prompt, for the moderators).