Consistent Reads and Reproducible Runs

Lesson 4 of 4

Hand a Run to Another Model

Estimated time: 10 minutes

Pass the state, not the conversation

A run that begins on one model and continues on another looks like a small change and behaves like a boundary. The next step reads what it is given, and if the handover changed the shape of that input, the step is now working with something slightly different from the thing it was written against.

Record the model with each step

Attribution is what makes a handover visible. Write the model that produced each step into the transcript, so a change in output shape or quality can be traced to the boundary instead of guessed at. Without it, the run reads as one continuous voice that quietly changed part way through.

Pass the run state, not the conversation

Replaying the whole conversation gives the next model more text to interpret and no clearer picture of the task. Passing the run state, the task and the open decision is shorter, and it does not depend on how the previous model chose to phrase things.

def handover(run, next_model, check_schema):
    response = next_model.ask({"state": run["state"], "task": run["task"]})
    if not check_schema(response, run["expected_schema"]):
        return {"ok": False, "reason": "shape_changed"}
    run["steps"].append({"model": next_model.name, "result": response})
    return {"ok": True}

Re-validate at the boundary

The check belongs at the boundary, not at the end of the run. Re-validate the structured response against the shape the downstream step expects, and hold the run when it does not match, rather than passing a differently shaped result onward to fail somewhere less obvious.

Choose the fallback by capability

A fallback is not whichever model answers first. Choose it by the capability the step needs, because a model that is fast and available but cannot follow the required shape is a worse fallback than one that is slower and correct.