Workshop material. This page records an investigation. A proposal here is not, by itself, an adopted Commonplace decision.

Frontloading as partial evaluation

Suppose a prompt says, “List the files in kb/notes/, then choose the one that best answers the user's question.” If the directory contents are known before the question arrives and remain valid for the call, the author can instead write, “Here are the files in kb/notes/: … Which one best answers the user's question?” The choice still depends on the question. Frontloading replaces the listing step with its result; it does not try to make the choice early.

Partial evaluation explains what changed between the two prompts. A partial evaluator takes a program P and its known inputs s and produces a residual program P_s for the remaining inputs d. The usual correctness condition is P_s(d) = P(s, d): whichever remaining inputs arrive, the specialized program gives the same result as the original. In the example, the prompt plays the role of P, the directory contents are s, and the question is d. Deciding that listing can happen early but selection must wait is the prompt author's binding-time analysis: it identifies which step depends on which inputs.

Divide-and-conquer explains why listing and selection can happen separately. Partial evaluation explains why the output of preparation is another prompt, not just a list. Instructions and data share a text medium, so the listing can take the place of the instruction that would produce it. The resulting prompt says what remains to be done.

The analogy describes that substitution, not a guarantee of identical answers. Natural-language instructions do not specify an exact function, so a model given the listing need not make the same choice as one asked to produce it first. The intended gain is context and reliability rather than runtime speed: the model can judge relevance without first issuing and interpreting a listing call.


Proposed citation for kb/notes/frontloading-spares-execution-context.md: Frontloading as partial evaluation explains how replacing a step with its known result leaves an instruction for the remaining judgment, without guaranteeing the same model response.