Skip to content

Commit 4ea1657

Browse files
chore(examples): soften 00 determinism wording + clarify 09 loop exit
- 00 hello-world: docstring + module comment described temperature=0.0 as making the run "reproduce deterministically", which over-promises. LLM APIs don't guarantee strict determinism even at temp 0 (provider-side batching, GPU sampling heuristics, model-version drift). Reworded to "reduces sampling variance" and "as reproducible as the API allows" so the pedagogical point (RuntimeConfig is the tuning knob) lands without an inaccurate guarantee. ``_DETERMINISTIC`` variable name kept as a recognizable shorthand for the demo. - 09 tool-use: docstring said the loop terminates when ``finish_reason="stop"``, but the route function actually checks whether the last AssistantMessage carries any ``tool_calls``. finish_reason isn't tracked in state. Reworded to match the implementation: "loop terminates when the assistant message has no tool_calls (the model is done requesting tools) or after a hard turn cap."
1 parent 833163d commit 4ea1657

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

examples/00-hello-world/main.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
instance on ``Response.parsed``.
1414
- JSON Schema dict (``research``): raw dict on ``Response.parsed``.
1515
- ``RuntimeConfig`` for per-call sampling knobs — every ``complete()``
16-
here passes ``config=RuntimeConfig(temperature=0.0)`` so the run
17-
reproduces deterministically.
16+
here passes ``config=RuntimeConfig(temperature=0.0)`` to reduce
17+
sampling variance across runs. Temperature 0 isn't a strict
18+
determinism guarantee (providers vary at the infra level) but it's
19+
the standard tuning knob for "as reproducible as the API allows."
1820
- Conditional routing on a parsed field (``route`` reads
1921
``state.classification.intent``).
2022
- ``attach_observer`` for boundary visibility.
@@ -87,10 +89,11 @@ class PipelineState(State):
8789
# builders, IDE inspection) import this module without running main().
8890
_provider_instance: OpenAIProvider | None = None
8991

90-
# Per-call sampling knobs. The demo locks the model at temperature 0
91-
# so the routing classification (and the rest of the run) reproduces
92-
# across invocations — useful for tutorial output, less appropriate
93-
# for production where some sampling variety is desirable.
92+
# Per-call sampling knobs. The demo sets temperature 0 to reduce
93+
# variance across invocations — the run is "as reproducible as the
94+
# API allows" but not strictly deterministic (providers vary at the
95+
# infra level even at temp 0). Useful for tutorial output; production
96+
# usually wants some sampling variety.
9497
# RuntimeConfig also surfaces max_tokens, top_p, and seed; only
9598
# temperature is set here so the others fall through to provider
9699
# defaults.

examples/09-tool-use/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
1212
The agent loops: send messages + tools to the model, dispatch any
1313
``tool_calls`` the model emits, feed the results back as
14-
``ToolMessage`` entries, and call the model again. Loop terminates when
15-
the model returns content with ``finish_reason="stop"`` (or after a
16-
hard turn cap).
14+
``ToolMessage`` entries, and call the model again. Loop terminates
15+
when the assistant message has no ``tool_calls`` (the model is done
16+
requesting tools) or after a hard turn cap.
1717
1818
**What's interesting in the implementation:**
1919

0 commit comments

Comments
 (0)