Skip to content

fix(examples): show the helpers each docs region calls - #187

Merged
marcusschiesser merged 2 commits into
mainfrom
marcusschiesser/structured-output-snapshot
Oct 21, 2026
Merged

marcusschiesser merged 2 commits into
mainfrom
marcusschiesser/structured-output-snapshot

Conversation

@marcusschiesser

@marcusschiesser marcusschiesser commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

docs.introspection.dev renders the # #region docs:<id> blocks through <SdkCode> at pinned tags (introspection-docs#248). At v0.29.0 several Python regions call helpers defined outside the region, so the docs show calls to code the reader never sees. This PR makes every region show each helper it calls, and fixes the original Codex finding on the docs PR (https://github.com/introspection-org/introspection-docs/pull/248#discussion_r4335902007, P2).

Regions changed

Region File Change
patterns/structured-output/read-stream patterns/structured_output.py Handles MESSAGES_SNAPSHOT (a reconnect past the replay buffer sends the run so far instead of the frames, so a finished submit_result was lost). The new from_snapshot helper is defined inside the region, before its use.
patterns/add-to-your-app/start-task patterns/add_to_your_app.py Minimal stubs for save_agent_binding and send_event_to_browser inside the region, each under a # Your app's code: ... comment. The module-level Orders store is gone; start_task returns the binding to main instead.
patterns/add-to-your-app/reconnect patterns/add_to_your_app.py Stub for send_event_to_browser inside the region.
reference/python/reattach reference/python_sdk.py Stub for render inside the region.

Region ids and markers are unchanged.

Audit

Every docs: region in the repo (22 files, all Python) was checked with an AST script for calls to functions, classes, methods or closures the example file defines outside the region. Only the four regions above had any. The remaining hits were SDK methods that share a name with the enclosing function (runs.resume, run.cancel, logs.feedback), not hidden helpers.

Rule

AGENTS.md (Examples) now says: a docs region must show every helper it calls that the example file defines. SDK work (stream parsing, snapshot recovery, text accumulation) goes inside the region before its use; the reader's own app code (render, save_agent_binding, ...) gets a minimal stub inside the region under a one-line # Your app's code comment.

Example-only change, no SDK API change.

Checks run locally: ruff format, ruff check, ty check, prek run --all-files, scripts/check_examples.py (compiles, imports resolve, regions paired).

🤖 Generated with Claude Code

…ured output

A reconnect behind the replay buffer answers with one MESSAGES_SNAPSHOT
instead of the tool-call frames, which the read-stream snippet ignored, so a
completed submit_result could be lost. A from_snapshot helper outside the
docs region replaces the collected arguments with the snapshot's tool calls,
as the JS, Rust and Swift snippets do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T11:58:02.557239Z 6777d0e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Move from_snapshot into the structured-output read-stream region and
replace hidden app placeholders (send_event_to_browser,
save_agent_binding, render) with minimal stubs inside the regions that
call them. AGENTS.md states the rule for later regions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@marcusschiesser marcusschiesser changed the title fix(examples): recover submit_result from MESSAGES_SNAPSHOT in structured output fix(examples): show the helpers each docs region calls Oct 21, 2026
@marcusschiesser

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 6777d0eee7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@marcusschiesser
marcusschiesser merged commit be3ed3d into main Oct 21, 2026
9 of 10 checks passed
@marcusschiesser
marcusschiesser deleted the marcusschiesser/structured-output-snapshot branch October 21, 2026 12:07

This branch was successfully deployed

1 active deployment
build — 6777d0ee Deployed Oct 21, 2026 by marcusschiesser via Unit Tests #507
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant