Truncated structured output: what each library does
====================================================

A local mock server returns the same invoice JSON four ways: complete, cut off
with finish_reason "length", cut off but still valid JSON with "length", and cut
off but mislabelled "stop". Each structured-output call is pointed at the mock
and the outcome is recorded. No API key is used and no provider is contacted.

Run it
------
  python3 -m venv venv && ./venv/bin/pip install -r requirements.txt
  npm install
  ./venv/bin/python mock_server.py 8765 &
  PYDANTIC_AI_NO_BANNER=1 ./venv/bin/python run_python.py 8765
  node run_node.mjs 8765
  ./venv/bin/python build_summary.py        # writes results-summary.md and results-matrix.svg
  ./venv/bin/python -m unittest test_guard -v

Files
-----
  mock_server.py        the mock (standard library only)
  run_python.py         openai, instructor, langchain-openai, pydantic-ai
  run_node.mjs          openai (node), Vercel AI SDK
  results-*.json        the recorded run that the article's table is built from
  results-summary.md    the table
  results-matrix.svg    the chart
  guard.py, test_guard.py   a finish-reason check with offline tests
  environment.txt       exact versions used for the recorded run

Limits
------
This measures client-library behaviour against a mock that imitates the OpenAI
Chat Completions and Responses response shapes. It does not measure how often
any model or provider truncates output, and a real provider may send fields the
mock does not. Streaming was not tested. Results apply to the pinned versions
in environment.txt; re-run after upgrading.
