inference("mock", ...) — an
offline stand-in, not a default ask() falls back to — so none of it
needs an API key.
1. Ask something
AModel is a value, and model NAME = inference("mock", name?, response_template:) names one — model is required here, not optional;
a plain weather_bot = inference(...) is a syntax error. This one needs
no network and no API key — good for learning, and for tests.
set delegation = <model> picks which model ask(...) talks to.
{prompt} in the template is replaced with whatever you pass to ask(...).
2. Read the answer safely
ask(...) never returns a plain string — it returns an Answer, with
.value, .confidence, and .source. You must write .value to get the
text out; there’s no implicit unwrapping, on purpose. That’s the whole
point: a model’s output stays visibly different from a fact your code
computed itself.
inference("mock", ...) always reports 0.5 confidence, since it’s a
deterministic stand-in, not a real judgment. A real provider (see
Model, Ask & Answer)
reports nil instead of faking a number.
3. Switch which model answers
set delegation can be reassigned as many times as you like. ask(...)
always uses whichever model is currently delegated to:
4. Scope a model choice to one block
session is a scope, not a separate actor — set delegation inside one
only affects that block. Once the block ends, delegation reverts to
whatever it was outside:
print is back to outer_model — the session’s own
delegation never leaked out.
What you built
model NAME = inference("mock", ...)— an offlineModel, for learning and tests (modelis required)set delegation = <model>— pick which modelask(...)usesask(prompt)→Answer—.value/.confidence/.source, no implicit unwrappingsession— a scope for trying a different model without affecting the rest of the program
Next
Safe Actions
Next tutorial — permissions and side effects that can’t happen by accident.
Model, Ask & Answer
The full reference — real providers, labeled arguments, capability gating.
Let a model choose a tool
The next step past a plain
ask() call — needs a real model.Which keyword do I want?
def vs tool vs action vs agent, decided in one glance.
