feat(scripts): add an opt-in live runner for the examples - #598
Draft
williedoran-neo4j wants to merge 1 commit into
Draft
feat(scripts): add an opt-in live runner for the examples#598williedoran-neo4j wants to merge 1 commit into
williedoran-neo4j wants to merge 1 commit into
Conversation
Nothing in CI executes anything under examples/, so a bulk model swap in neo4j#482 left 16 files passing parameters their model rejects. The failures were deterministic - nobody had run them. Adds scripts/check_examples.py, which resolves each example's provider and model, skips the ones there are no credentials or services for, and runs the rest against the live APIs. Static rules cover the parameter combinations providers reject outright - OpenAI reasoning models refuse max_tokens and any temperature but the default, while Anthropic requires max_tokens - so an obvious break is caught before spending a call on it. Deliberately opt-in. It costs money and hits the network, so it is a manual-stage pre-commit hook and nothing runs it on a commit, a push, or in CI: uv run pre-commit run --hook-stage manual examples-live Unit tests cover the rules against source strings, with no network, no API key and no temp files, including the two false-positive guards that are easy to regress: AnthropicLLM requires max_tokens, and Ollama nests its parameters under options. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #578 so the example fixes there can be reviewed as a plain bug fix.
Nothing in CI executes anything under
examples/, so a bulk model swap in #482 left 17 files passing parameters their model rejects. The failures were deterministic — nobody had run them.What's here
scripts/check_examples.pyresolves each example's provider and model, skips the ones there are no credentials or services for, and runs the rest against the live APIs. Static rules cover the parameter combinations providers reject outright — OpenAI reasoning models refusemax_tokensand any temperature but the default, while Anthropic requiresmax_tokens— so an obvious break is caught before spending a call on it.Deliberately opt-in
It costs money and hits the network, so nothing runs it on a commit, a push, or in CI. It is a manual-stage pre-commit hook, run when you mean it:
The hook carries
always_run: true; without it pre-commit skips a non-file-driven hook whenever nothing matching is staged, and the command silently does nothing.The trade-off is worth stating plainly: because nothing runs automatically, this catches drift only when somebody chooses to run it. It is a tool for before a release or after touching the examples, not a guard rail.
Tests
tests/unit/scripts/test_check_examples.py— 24 cases fed as source strings. No network, no API key, no temp files.They exist because the rules are the part that has to be trusted, and writing them found two real defects:
model_paramsbound to a variable resolved to an empty dict, so every rule silently skipped — which is how a broken example survived a first pass — and a validChatOpenAI(temperature=1)was reported with the self-contradictory fix "or pass temperature=1". Both tests were confirmed to fail against the pre-fix code. They also pin the two false-positive guards that are easy to regress: Anthropic's requiredmax_tokens, and Ollama nesting parameters underoptions.scripts/sits outside the coverage gate ([tool.coverage.run] source = ["src"]), so these are additive and cannot move the 90% number. They need one line of wiring,pythonpath = ["scripts"].Type of Change
Complexity
Complexity: Low
How Has This Been Tested?
Green on
ruff,mypy --strictand the unit suite. Run againstmainthe static rules report 22 problems across 17 example files — the ones #578 fixes.Checklist
🤖 Generated with Claude Code