{"id":"64IbU2vI","creatorId":"sZ73VVxwT8PO62W11xfAZIrg2yOa0oWr","title":null,"createdAt":1780964404219,"updatedAt":1780964404219,"latestVersionNum":1,"versions":[{"versionNum":1,"version":"1.106.0","branchName":null,"branchSha":null,"runRelease":true,"runBranch":false,"sdkDeps":null,"snippets":[{"id":"stream_break","name":"test_01_clean_early_break_history.py","code":"# #5615/#5619 acceptance: clean early break records partial history after run_stream exits.\n\nimport anyio\n\nfrom pydantic_ai import Agent\nfrom pydantic_ai.models.function import FunctionModel\n\n\nasync def stream_text(_messages, _info):\n    for chunk in ['alpha', ' beta', ' gamma']:\n        yield chunk\n        await anyio.sleep(0)\n\n\nasync def main():\n    agent = Agent(FunctionModel(stream_function=stream_text), output_type=str)\n\n    async with agent.run_stream('test') as result:\n        async for _chunk in result.stream_text(delta=True):\n            break\n\n        # The stronger inside-context synchronous flip is tracked separately in #5756.\n        assert result.is_complete is False\n\n    assert result.is_complete is True\n    assert result.response.state == 'interrupted'\n    assert getattr(result.all_messages()[-1], 'state', None) == 'interrupted'\n\n\nawait main()\n","primaryOutput":{"output":"\n==================================== ERRORS ====================================\n\u001b[31m\u001b[1m________________________ ERROR collecting test_repro.py ________________________\u001b[0m\n\u001b[31m/lib/python3.13/site-packages/_pytest/python.py:493: in importtestmodule\n    mod = import_path(\n/lib/python3.13/site-packages/_pytest/pathlib.py:587: in import_path\n    importlib.import_module(module_name)\n/lib/python313.zip/importlib/__init__.py:88: in import_module\n    return _bootstrap._gcd_import(name[level:], package, level)\n<frozen importlib._bootstrap>:1387: in _gcd_import\n    ???\n<frozen importlib._bootstrap>:1360: in _find_and_load\n    ???\n<frozen importlib._bootstrap>:1331: in _find_and_load_unlocked\n    ???\n<frozen importlib._bootstrap>:935: in _load_unlocked\n    ???\n/lib/python3.13/site-packages/_pytest/assertion/rewrite.py:176: in exec_module\n    source_stat, co = _rewrite_test(fn, self.config)\n/lib/python3.13/site-packages/_pytest/assertion/rewrite.py:358: in _rewrite_test\n    co = compile(tree, strfn, \"exec\", dont_inherit=True)\nE     File \"/tmp/test_repro.py\", line 32\nE       await main()\nE       ^^^^^^^^^^^^\nE   SyntaxError: 'await' outside async function\u001b[0m\n\u001b[33m=============================== warnings summary ===============================\u001b[0m\n../../lib/python3.13/site-packages/_pytest/config/__init__.py:1277\n  /lib/python3.13/site-packages/_pytest/config/__init__.py:1277: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: anyio\n    self._mark_plugins_for_rewrite(hook)\n\n-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html\n\u001b[36m\u001b[1m=========================== short test summary info ============================\u001b[0m\n\u001b[31mERROR\u001b[0m ../../tmp/test_repro.py\n!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!\n\u001b[31m\u001b[33m1 warning\u001b[0m, \u001b[31m\u001b[1m1 error\u001b[0m\u001b[31m in 1.17s\u001b[0m\u001b[0m\n","error":null,"exitCode":2},"comparisonOutput":null},{"id":"explicit_cancel","name":"test_02_explicit_cancel_history.py","code":"# #5313/#5364 acceptance: explicit cancel records interrupted response immediately.\n\nimport anyio\n\nfrom pydantic_ai import Agent\nfrom pydantic_ai.models.function import FunctionModel\n\n\nasync def stream_text(_messages, _info):\n    for chunk in ['alpha', ' beta', ' gamma']:\n        yield chunk\n        await anyio.sleep(0)\n\n\nasync def main():\n    agent = Agent(FunctionModel(stream_function=stream_text), output_type=str)\n\n    async with agent.run_stream('test') as result:\n        await anext(result.stream_text(delta=True))\n        await result.cancel()\n\n        assert result.is_complete is True\n        assert result.response.state == 'interrupted'\n        assert getattr(result.all_messages()[-1], 'state', None) == 'interrupted'\n\n\nawait main()\n","primaryOutput":{"output":"\n==================================== ERRORS ====================================\n\u001b[31m\u001b[1m________________________ ERROR collecting test_repro.py ________________________\u001b[0m\n\u001b[31m/lib/python3.13/site-packages/_pytest/python.py:493: in importtestmodule\n    mod = import_path(\n/lib/python3.13/site-packages/_pytest/pathlib.py:587: in import_path\n    importlib.import_module(module_name)\n/lib/python313.zip/importlib/__init__.py:88: in import_module\n    return _bootstrap._gcd_import(name[level:], package, level)\n<frozen importlib._bootstrap>:1387: in _gcd_import\n    ???\n<frozen importlib._bootstrap>:1360: in _find_and_load\n    ???\n<frozen importlib._bootstrap>:1331: in _find_and_load_unlocked\n    ???\n<frozen importlib._bootstrap>:935: in _load_unlocked\n    ???\n/lib/python3.13/site-packages/_pytest/assertion/rewrite.py:176: in exec_module\n    source_stat, co = _rewrite_test(fn, self.config)\n/lib/python3.13/site-packages/_pytest/assertion/rewrite.py:358: in _rewrite_test\n    co = compile(tree, strfn, \"exec\", dont_inherit=True)\nE     File \"/tmp/test_repro.py\", line 29\nE       await main()\nE       ^^^^^^^^^^^^\nE   SyntaxError: 'await' outside async function\u001b[0m\n\u001b[33m=============================== warnings summary ===============================\u001b[0m\n../../lib/python3.13/site-packages/_pytest/config/__init__.py:1277\n  /lib/python3.13/site-packages/_pytest/config/__init__.py:1277: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: anyio\n    self._mark_plugins_for_rewrite(hook)\n\n-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html\n\u001b[36m\u001b[1m=========================== short test summary info ============================\u001b[0m\n\u001b[31mERROR\u001b[0m ../../tmp/test_repro.py\n!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!\n\u001b[31m\u001b[33m1 warning\u001b[0m, \u001b[31m\u001b[1m1 error\u001b[0m\u001b[31m in 0.42s\u001b[0m\u001b[0m\n","error":null,"exitCode":2},"comparisonOutput":null},{"id":"cancel_complete","name":"test_03_cancel_after_complete_state.py","code":"# #5782/#5795 acceptance: defensive cancel after a complete stream is a no-op for response state.\n\nimport anyio\n\nfrom pydantic_ai import Agent\nfrom pydantic_ai.models.test import TestModel\n\n\nasync def main():\n    agent = Agent(TestModel(custom_output_text='done'))\n\n    async with agent.run_stream('test') as result:\n        assert await result.get_output() == 'done'\n        assert result.response.state == 'complete'\n\n        await result.cancel()\n\n        assert result.is_complete is True\n        assert result.response.state == 'complete'\n        assert getattr(result.all_messages()[-1], 'state', None) == 'complete'\n\n\nawait main()\n","primaryOutput":{"output":"\n==================================== ERRORS ====================================\n\u001b[31m\u001b[1m________________________ ERROR collecting test_repro.py ________________________\u001b[0m\n\u001b[31m/lib/python3.13/site-packages/_pytest/python.py:493: in importtestmodule\n    mod = import_path(\n/lib/python3.13/site-packages/_pytest/pathlib.py:587: in import_path\n    importlib.import_module(module_name)\n/lib/python313.zip/importlib/__init__.py:88: in import_module\n    return _bootstrap._gcd_import(name[level:], package, level)\n<frozen importlib._bootstrap>:1387: in _gcd_import\n    ???\n<frozen importlib._bootstrap>:1360: in _find_and_load\n    ???\n<frozen importlib._bootstrap>:1331: in _find_and_load_unlocked\n    ???\n<frozen importlib._bootstrap>:935: in _load_unlocked\n    ???\n/lib/python3.13/site-packages/_pytest/assertion/rewrite.py:176: in exec_module\n    source_stat, co = _rewrite_test(fn, self.config)\n/lib/python3.13/site-packages/_pytest/assertion/rewrite.py:358: in _rewrite_test\n    co = compile(tree, strfn, \"exec\", dont_inherit=True)\nE     File \"/tmp/test_repro.py\", line 25\nE       await main()\nE       ^^^^^^^^^^^^\nE   SyntaxError: 'await' outside async function\u001b[0m\n\u001b[33m=============================== warnings summary ===============================\u001b[0m\n../../lib/python3.13/site-packages/_pytest/config/__init__.py:1277\n  /lib/python3.13/site-packages/_pytest/config/__init__.py:1277: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: anyio\n    self._mark_plugins_for_rewrite(hook)\n\n-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html\n\u001b[36m\u001b[1m=========================== short test summary info ============================\u001b[0m\n\u001b[31mERROR\u001b[0m ../../tmp/test_repro.py\n!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!\n\u001b[31m\u001b[33m1 warning\u001b[0m, \u001b[31m\u001b[1m1 error\u001b[0m\u001b[31m in 0.45s\u001b[0m\u001b[0m\n","error":null,"exitCode":2},"comparisonOutput":null},{"id":"future_run_cancel","name":"test_04_future_run_cancel_contract.py","code":"# New issue acceptance sketch: define whole-agent-run cancellation semantics.\n# This should become executable only after the public API is designed.\n\nimport pytest\n\npytest.xfail('pending design: whole-agent-run cancellation API/result contract')\n\n# Desired shape to settle in the issue:\n#\n# async with agent.iter('test') as run:\n#     result = await run.cancel(reason='user_cancelled')\n#\n# assert result.is_complete is True\n# assert getattr(result.all_messages()[-1], 'state', None) == 'interrupted'\n# assert result.cancel_reason == 'user_cancelled'\n","primaryOutput":{"output":"\u001b[33mx\u001b[0m\u001b[33m                                                                        [100%]\u001b[0m\n\u001b[33m=============================== warnings summary ===============================\u001b[0m\n../../lib/python3.13/site-packages/_pytest/config/__init__.py:1277\n  /lib/python3.13/site-packages/_pytest/config/__init__.py:1277: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: anyio\n    self._mark_plugins_for_rewrite(hook)\n\n-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html\n\u001b[33m\u001b[33m\u001b[1m1 xfailed\u001b[0m, \u001b[33m\u001b[1m1 warning\u001b[0m\u001b[33m in 0.02s\u001b[0m\u001b[0m\n","error":null,"exitCode":0},"comparisonOutput":null},{"id":"future_tool_cancel","name":"test_05_future_tool_cancel_contract.py","code":"# New issue acceptance sketch: define tool-execution cancellation semantics.\n# This is distinct from merely cancelling asyncio tasks; it defines user-visible history/replay behavior.\n\nimport pytest\n\npytest.xfail('pending design: cancelled tool-call history and model-visible semantics')\n\n# Desired constraints to settle in the issue:\n#\n# - cancellation while tools are running should not silently drop completed tool results\n# - cancelled tool calls should have an explicit representation in message history, or an explicit policy saying they do not\n# - if the LLM is resumed, it should either see synthetic cancelled tool returns or replay should require an explicit policy\n# - cancellation should not leave background tool tasks running after the public cancellation await returns\n","primaryOutput":{"output":"\u001b[33mx\u001b[0m\u001b[33m                                                                        [100%]\u001b[0m\n\u001b[33m=============================== warnings summary ===============================\u001b[0m\n../../lib/python3.13/site-packages/_pytest/config/__init__.py:1277\n  /lib/python3.13/site-packages/_pytest/config/__init__.py:1277: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: anyio\n    self._mark_plugins_for_rewrite(hook)\n\n-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html\n\u001b[33m\u001b[33m\u001b[1m1 xfailed\u001b[0m, \u001b[33m\u001b[1m1 warning\u001b[0m\u001b[33m in 0.06s\u001b[0m\u001b[0m\n","error":null,"exitCode":0},"comparisonOutput":null},{"id":"future_replay","name":"test_06_future_interrupted_replay_policy.py","code":"# New issue acceptance sketch: define replay semantics for interrupted histories.\n# Capturing ModelResponse/ModelRequest(state='interrupted') is not enough; replay policy must be explicit.\n\nimport pytest\n\npytest.xfail('pending design: replay/resume policy for interrupted message histories')\n\n# Desired constraints to settle in the issue:\n#\n# - passing interrupted history back into agent.run(..., message_history=...) should not silently do the wrong thing\n# - either replay is rejected with a clear error, or callers must choose a policy such as drop/keep/repair\n# - incomplete tool-call args and missing tool results need provider-safe behavior across OpenAI/Anthropic/Google\n# - docs should show the supported pattern for persisting then resuming after cancellation\n","primaryOutput":{"output":"\u001b[33mx\u001b[0m\u001b[33m                                                                        [100%]\u001b[0m\n\u001b[33m=============================== warnings summary ===============================\u001b[0m\n../../lib/python3.13/site-packages/_pytest/config/__init__.py:1277\n  /lib/python3.13/site-packages/_pytest/config/__init__.py:1277: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: anyio\n    self._mark_plugins_for_rewrite(hook)\n\n-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html\n\u001b[33m\u001b[33m\u001b[1m1 xfailed\u001b[0m, \u001b[33m\u001b[1m1 warning\u001b[0m\u001b[33m in 0.02s\u001b[0m\u001b[0m\n","error":null,"exitCode":0},"comparisonOutput":null}],"createdAt":1780964404219}]}