diff --git a/VERSION b/VERSION index 04a373e..c5523bd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.16.0 +0.17.0 diff --git a/pyproject.toml b/pyproject.toml index a40a2bf..851d222 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "arkruntime" -version = "0.16.0" +version = "0.17.0" description = "Ark runtime SDK for Python" readme = "README.md" requires-python = ">=3.8" diff --git a/src/arkruntime/types/session/session_stream_shim.py b/src/arkruntime/types/session/session_stream_shim.py index ffa2bda..9dde9d8 100644 --- a/src/arkruntime/types/session/session_stream_shim.py +++ b/src/arkruntime/types/session/session_stream_shim.py @@ -77,6 +77,8 @@ class ManagedAgentsStopReason(_DictCompatModel): """ type: str = "" + # Pending input event IDs when type is requires_action. + event_ids: Optional[List[str]] = None class ManagedAgentsRetryStatus(_DictCompatModel): diff --git a/tests/test_ark_apis_stop_reason_sync.py b/tests/test_ark_apis_stop_reason_sync.py new file mode 100644 index 0000000..cc2c607 --- /dev/null +++ b/tests/test_ark_apis_stop_reason_sync.py @@ -0,0 +1,39 @@ +# Copyright (c) 2026 ByteDance Ltd. and/or its affiliates. +# SPDX-License-Identifier: Apache-2.0 + +"""Synced from ark-apis by vendor-session; exercise the real stream decoder.""" + +import unittest + +from arkruntime.types.session import ManagedAgentsStopReason, decode_session_event + + +class StreamStopReasonTests(unittest.TestCase): + def test_typed_pending_event_ids(self): + self.assertIn("event_ids", ManagedAgentsStopReason.model_fields) + for kind in ("session.status_idle", "session.thread_status_idle"): + for ids in (["sevt-a", "sevt-b"], ["sevt-b"], []): + payload = { + "type": kind, + "id": "sevt-idle", + "stop_reason": {"type": "requires_action", "event_ids": ids}, + } + if kind == "session.thread_status_idle": + payload.update(session_thread_id="sthr-1", agent_name="agent") + with self.subTest(kind=kind, ids=ids): + event = decode_session_event(payload) + self.assertIsInstance(event.stop_reason, ManagedAgentsStopReason) + self.assertEqual(event.stop_reason.event_ids, ids) + self.assertEqual(event.stop_reason["event_ids"], ids) + self.assertEqual(event.model_dump(exclude_unset=True), payload) + + def test_legacy_and_future_reasons(self): + for kind in ("end_turn", "retries_exhausted", "future_reason"): + with self.subTest(kind=kind): + reason = ManagedAgentsStopReason(type=kind) + self.assertIsNone(reason.event_ids) + self.assertEqual(reason.model_dump(exclude_unset=True), {"type": kind}) + + +if __name__ == "__main__": + unittest.main() diff --git a/uv.lock b/uv.lock index a6ae632..572a22c 100644 --- a/uv.lock +++ b/uv.lock @@ -79,7 +79,7 @@ wheels = [ [[package]] name = "arkruntime" -version = "0.16.0" +version = "0.17.0" source = { editable = "." } dependencies = [ { name = "anyio", version = "4.5.2", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.9'" },