Skip to content

five-on-it / apps/creator/src/runner

apps/creator/src/runner ​

One turn of a creation's conversation, run (TECHNICAL_SPECS §9.8): the loop of a model's calls over the creation's tools (tools.ts, the MCP server in this process as the job's own session), from what the owner said to the model's answer, within the turn's caps: LIMITS (the model's calls, its tokens in and out, the most it answers with) and the API's (caps: what is left of the creation's dollars, its minutes; its builds the API counts). The first turn starts from the brief; a later one goes on from the model's own history of the turns before (the API keeps it as the transcript), the tools' long answers cut short, with the owner's new messages after it. The turn ends when the model answers without calling a tool (a game built, a question, a proposal: its words go to the owner). It fails when the same errors come back from two builds in a row (the turn's fault), and when the model's provider or the API cannot be reached (no fault of the owner's: system).

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).

Interfaces ​

Functions ​