Executing Steps and Passing Results Forward

step execution with result references

Part of: Multi-Step Task Agent

The plan runs in the right order now, but a gap remains. Step 2 needs the actual number step 1 found, not merely the fact that step 1 ran first. This lesson wires real data out of one step's output and into the next step's input. Referencing an earlier step's result Give each step's arguments the ability to point at a prior result instead of hard-coding a value: Before dispatching step 2, you substitute {{step1.result}} with whatever step 1 actually returned. If you're building a scripted, fixed-plan agent like this one, that substitution is your job in plain Python. If instead you let the model decide each turn using the API's live tools parameter, this happens differently: you keep every tool result block in the growing messages list, and the model reads earlier results back out of that history itself on its next turn. Same idea, two different mechanisms, one your code resolves explicitly, one the model resolves by re-reading the conversation. A resolver for our fixed-plan agent This is a simplified reference format, "$step1" instead of "{{step1.result}}", but the mechanics are identical: check whether a value is a reference, look up the referenced step's stored result, and subst

Challenge: Resolve Step References