Skip to content

OpenAI Context Demo

If you want to understand each argument step by step, start here first:

Start with the minimal script:

python3.13 -m venv .venv-user
source .venv-user/bin/activate
python -m pip install --upgrade pip
python -m pip install -e packages/context_core -e packages/provider_openai -e packages/sdk
python examples/openai_context_demo/embedding_example.py

What it shows:

  1. a real messages = [...] transcript with inline tool call/result events
  2. StatePlaneSession(...)
  3. session.transform(...)
  4. candidate ids before compilation
  5. selected and excluded ids after compilation
  6. the exact OpenAI call shape

The example also includes retrieved_context=[...] so you can see how retrieved snippets are kept separate from the transcript before StatePlane renders the final OpenAI payload.

The key line is:

client.responses.create(**prepared.rendered_request.to_responses_create_kwargs())

That is the product boundary. Your app still calls OpenAI. StatePlane decides what belongs in that call first.

If you want the same flow in a notebook, open:

  • examples/notebooks/openai_context_demo.ipynb

That notebook is now the interactive companion to the parameter tutorial.

If you want the heavier comparison harness, use:

  • examples/openai_context_demo/comparison_example.py

That advanced example is for deeper inspection. It is not the default onboarding path.