lp-agent-runtime-sdk 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,182 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of submitting and
55
+ discussing improvements to the Work, but excluding communication that is
56
+ conspicuously marked or designated in writing by the copyright owner as
57
+ "Not a Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and included
61
+ within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by the combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a cross-claim
80
+ or counterclaim in a lawsuit) alleging that the Work or any Contribution
81
+ embodied within the Work constitutes direct or contributory patent
82
+ infringement, then any patent licenses granted to You under this License
83
+ for that Work shall terminate as of the date such litigation is filed.
84
+
85
+ 4. Redistribution. You may reproduce and distribute copies of the
86
+ Work or Derivative Works thereof in any medium, with or without
87
+ modifications, and in Source or Object form, provided that You
88
+ meet the following conditions:
89
+
90
+ (a) You must give any other recipients of the Work or Derivative
91
+ Works a copy of this License; and
92
+
93
+ (b) You must cause any modified files to carry prominent notices
94
+ stating that You changed the files; and
95
+
96
+ (c) You must retain, in the Source form of any Derivative Works
97
+ that You distribute, all copyright, patent, trademark, and
98
+ attribution notices from the Source form of the Work,
99
+ excluding those notices that do not pertain to any part of
100
+ the Derivative Works; and
101
+
102
+ (d) If the Work includes a "NOTICE" text file as part of its
103
+ distribution, You must include a readable copy of the
104
+ attribution notices contained within such NOTICE file, in
105
+ at least one of the following places: within a NOTICE text
106
+ file distributed as part of the Derivative Works; within
107
+ the Source form or documentation, if provided along with the
108
+ Derivative Works; or, within a display generated by the
109
+ Derivative Works, if and wherever such third-party notices
110
+ normally appear. The contents of the NOTICE file are for
111
+ informational purposes only and do not modify the License.
112
+ You may add Your own attribution notices within Derivative
113
+ Works that You distribute, alongside or as an addendum to
114
+ the NOTICE text from the Work, provided that such additional
115
+ attribution notices cannot be construed as modifying the License.
116
+
117
+ You may add Your own license statement for Your modifications and
118
+ may provide additional grant of rights to use, copy, modify, merge,
119
+ publish, distribute, sublicense, and/or sell copies of the
120
+ Contribution, either on an inclusive or exclusive basis.
121
+
122
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
123
+ any Contribution intentionally submitted for inclusion in the Work
124
+ by You to the Licensor shall be under the terms and conditions of
125
+ this License, without any additional terms or conditions.
126
+ Notwithstanding the above, nothing herein shall supersede or modify
127
+ the terms of any separate license agreement you may have executed
128
+ with Licensor regarding such Contributions.
129
+
130
+ 6. Trademarks. This License does not grant permission to use the trade
131
+ names, trademarks, service marks, or product names of the Licensor,
132
+ except as required for reasonable and customary use in describing the
133
+ origin of the Work and reproducing the content of the NOTICE file.
134
+
135
+ 7. Disclaimer of Warranty. Unless required by applicable law or
136
+ agreed to in writing, Licensor provides the Work (and each
137
+ Contributor provides its Contributions) on an "AS IS" BASIS,
138
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
139
+ implied, including, without limitation, any warranties or conditions
140
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
141
+ PARTICULAR PURPOSE. You are solely responsible for determining the
142
+ appropriateness of using or reproducing the Work and assume any
143
+ risks associated with Your exercise of permissions under this License.
144
+
145
+ 8. Limitation of Liability. In no event and under no legal theory,
146
+ whether in tort (including negligence), contract, or otherwise,
147
+ unless required by applicable law (such as deliberate and grossly
148
+ negligent acts) or agreed to in writing, shall any Contributor be
149
+ liable to You for damages, including any direct, indirect, special,
150
+ incidental, or exemplary damages of any character arising as a
151
+ result of this License or out of the use or inability to use the
152
+ Work (including but not limited to damages for loss of goodwill,
153
+ work stoppage, computer failure or malfunction, or all other
154
+ commercial damages or losses), even if such Contributor has been
155
+ advised of the possibility of such damages.
156
+
157
+ 9. Accepting Warranty or Liability. While redistributing the Work or
158
+ Derivative Works thereof, You may choose to offer, and charge a fee
159
+ for, acceptance of support, warranty, indemnity, or other liability
160
+ obligations and/or rights consistent with this License. However, in
161
+ accepting such obligations, You may offer such obligations only on
162
+ Your own behalf and on Your sole responsibility, not on behalf of
163
+ any other Contributor, and only if You agree to indemnify, defend,
164
+ and hold each Contributor harmless for any liability incurred by,
165
+ or claims asserted against, such Contributor by reason of your
166
+ accepting any such warranty or additional liability.
167
+
168
+ END OF TERMS AND CONDITIONS
169
+
170
+ Copyright 2026 Levelplane AI
171
+
172
+ Licensed under the Apache License, Version 2.0 (the "License");
173
+ you may not use this file except in compliance with the License.
174
+ You may obtain a copy of the License at
175
+
176
+ http://www.apache.org/licenses/LICENSE-2.0
177
+
178
+ Unless required by applicable law or agreed to in writing, software
179
+ distributed under the License is distributed on an "AS IS" BASIS,
180
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
181
+ See the License for the specific language governing permissions and
182
+ limitations under the License.
@@ -0,0 +1,203 @@
1
+ Metadata-Version: 2.4
2
+ Name: lp-agent-runtime-sdk
3
+ Version: 0.1.0
4
+ Summary: Python SDK for agent-runtime — invoke declarative agent workflows from Python
5
+ Author-email: Aditya Vinodh Arjun <aditya.vinodh@levelplane.ai>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/levelplaneai/agent-runtime-python
8
+ Project-URL: Repository, https://github.com/levelplaneai/agent-runtime-python
9
+ Project-URL: Issues, https://github.com/levelplaneai/agent-runtime-python/issues
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Operating System :: MacOS
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Operating System :: Microsoft :: Windows
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Dynamic: license-file
22
+
23
+ # lp-agent-runtime-sdk
24
+
25
+ Python SDK for running [agent-runtime](https://github.com/levelplaneai/agent-runtime) workflows. Wraps the agent-runtime binary to execute declarative `.agent` bundles from Python, with support for registering Python functions as callable tools.
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ pip install lp-agent-runtime-sdk
31
+ # or
32
+ uv add lp-agent-runtime-sdk
33
+ ```
34
+
35
+ The package ships pre-built binaries for macOS (arm64, amd64), Linux (amd64, arm64), and Windows (amd64) — no separate install required.
36
+
37
+ ## Quick Start
38
+
39
+ ```python
40
+ from agent_runtime import Runtime, RunError
41
+
42
+ rt = Runtime()
43
+
44
+ @rt.tool("pricing.get_quote", version="v1")
45
+ def get_quote(sku: str, quantity: int) -> dict:
46
+ return {"unit_price": 9.99, "currency": "USD"}
47
+
48
+ try:
49
+ output = rt.run("./my_bundle.agent", inputs={"sku": "ABC-1", "quantity": 10})
50
+ print(output)
51
+ except RunError as e:
52
+ print(f"Flow failed: {e} (run_id={e.run_id})")
53
+ ```
54
+
55
+ ## Authoring Bundles
56
+
57
+ Bundles are directories with a `.agent` extension containing a declarative flow definition. See [FLOWS.md](https://github.com/levelplaneai/agent-runtime/blob/main/FLOWS.md) in the main repo for the full authoring guide.
58
+
59
+ ## API Reference
60
+
61
+ ### `Runtime(binary=None, env=None)`
62
+
63
+ Creates a runtime instance.
64
+
65
+ - `binary` — explicit path to the `agent-runtime` binary (optional)
66
+ - `env` — extra environment variables merged into the subprocess environment
67
+
68
+ ### `@rt.tool(name, version="v1")`
69
+
70
+ Decorator that registers a Python function as a tool callable by the workflow. The tool reference inside the bundle must match `name@version`.
71
+
72
+ ```python
73
+ @rt.tool("supplier_api.get_price", version="v1")
74
+ def get_price(item_code: str) -> dict:
75
+ return {"price": 42.0}
76
+
77
+ # Async tools are also supported
78
+ @rt.tool("data.fetch_record", version="v1")
79
+ async def fetch_record(record_id: str) -> dict:
80
+ ...
81
+ ```
82
+
83
+ ### `rt.run(bundle, inputs=None, on_event=None) -> dict`
84
+
85
+ Executes a bundle synchronously and returns the flow output as a dict.
86
+
87
+ ### `rt.arun(bundle, inputs=None, on_event=None) -> dict`
88
+
89
+ Async version of `run`. Use with `await` inside an async context.
90
+
91
+ ```python
92
+ result = await rt.arun("./bundle.agent", inputs={"query": "hello"})
93
+ ```
94
+
95
+ ### `rt.validate(bundle)`
96
+
97
+ Validates a bundle directory. Raises `RuntimeError` if the bundle is invalid.
98
+
99
+ ## File Inputs
100
+
101
+ Use `FileInput` to pass a local file as a flow input. The path is resolved to an absolute path automatically.
102
+
103
+ ```python
104
+ from agent_runtime import Runtime, FileInput
105
+
106
+ rt = Runtime()
107
+ output = rt.run("./ocr_bundle.agent", inputs={"document": FileInput("./invoice.pdf")})
108
+ ```
109
+
110
+ ## Streaming Events
111
+
112
+ Pass an `on_event` callback to receive `TraceEvent` objects as the workflow executes.
113
+
114
+ ```python
115
+ def on_event(event: TraceEvent) -> None:
116
+ print(f"[{event.event}] node={event.node} duration={event.duration_ms}ms")
117
+
118
+ rt.run("./bundle.agent", inputs={...}, on_event=on_event)
119
+ ```
120
+
121
+ Key `TraceEvent` fields:
122
+
123
+ | Field | Type | Description |
124
+ |---|---|---|
125
+ | `event` | `str` | Event type (e.g. `node.start`, `node.done`, `tool.call`) |
126
+ | `node` | `str` | Node name in the flow |
127
+ | `node_type` | `str` | Node type (e.g. `llm`, `tool`, `router`) |
128
+ | `tool` | `str` | Tool reference if a tool was called |
129
+ | `model` | `str` | Model name for LLM nodes |
130
+ | `input_tokens` | `int` | Tokens consumed |
131
+ | `output_tokens` | `int` | Tokens produced |
132
+ | `duration_ms` | `int` | Node execution time |
133
+ | `error` | `str` | Error message if the node failed |
134
+ | `output` | `dict` | Node output |
135
+
136
+ ## Traces & Debugging
137
+
138
+ ### Where traces go
139
+
140
+ Trace events are emitted by the runtime binary to stdout as newline-delimited JSON and streamed to you in real time via the `on_event` callback. There is no separate log file — if you don't attach a callback, events are silently consumed and discarded.
141
+
142
+ To capture a full trace for debugging, collect all events into a list:
143
+
144
+ ```python
145
+ from agent_runtime import Runtime, TraceEvent, RunError
146
+
147
+ rt = Runtime()
148
+ trace: list[TraceEvent] = []
149
+
150
+ try:
151
+ output = rt.run("./bundle.agent", inputs={...}, on_event=trace.append)
152
+ except RunError as e:
153
+ # Flow-level failure — the error message and run_id are on the exception.
154
+ # Check the trace for the node that produced the error.
155
+ failed = [ev for ev in trace if ev.error]
156
+ for ev in failed:
157
+ print(f"node={ev.node} error={ev.error}")
158
+ raise
159
+ ```
160
+
161
+ ### Event types
162
+
163
+ | Event | When it fires |
164
+ |---|---|
165
+ | `flow_start` | Flow begins executing |
166
+ | `flow_done` | Flow completed successfully |
167
+ | `node_start` | A node begins executing |
168
+ | `node_done` | A node finished (check `ev.error` for failure) |
169
+ | `tool_call` | The runtime is calling a registered tool |
170
+ | `tool_done` | Tool call returned |
171
+
172
+ ### Error channels
173
+
174
+ There are two ways a run can surface an error:
175
+
176
+ **Node-level** — a node fails but the flow may continue (e.g. a retry). Delivered as a `TraceEvent` with `event="node_done"` and a non-empty `error` field. The `attempt` and `max_retries` fields indicate retry state.
177
+
178
+ **Flow-level** — the flow terminates in an error state. The SDK raises `RunError` with the message and `run_id`. Check the collected trace to find which node caused it.
179
+
180
+ **Binary crash** — the `agent-runtime` process exits with a non-zero code (misconfigured bundle, missing env var, etc.). The SDK raises `RuntimeError` with the stderr output as the message. This is distinct from a flow error and does not produce a `RunError`.
181
+
182
+ ### Typical debug loop
183
+
184
+ 1. Collect the full trace with `on_event=trace.append`
185
+ 2. On `RunError`, filter `[ev for ev in trace if ev.error]` to find the failing node
186
+ 3. Inspect `ev.inputs`, `ev.args`, and `ev.output` on surrounding events to understand the data at that point
187
+ 4. Fix the bundle or tool, then re-run
188
+
189
+ ## Binary Resolution
190
+
191
+ The SDK locates the `agent-runtime` binary in this order:
192
+
193
+ 1. `binary` argument passed to `Runtime()`
194
+ 2. `AGENT_RUNTIME_BIN` environment variable
195
+ 3. Bundled platform binary (included in the package)
196
+ 4. `agent-runtime` on `PATH`
197
+
198
+ ## Development
199
+
200
+ ```bash
201
+ uv run pytest # run tests
202
+ uv run ruff check . # lint
203
+ ```
@@ -0,0 +1,181 @@
1
+ # lp-agent-runtime-sdk
2
+
3
+ Python SDK for running [agent-runtime](https://github.com/levelplaneai/agent-runtime) workflows. Wraps the agent-runtime binary to execute declarative `.agent` bundles from Python, with support for registering Python functions as callable tools.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install lp-agent-runtime-sdk
9
+ # or
10
+ uv add lp-agent-runtime-sdk
11
+ ```
12
+
13
+ The package ships pre-built binaries for macOS (arm64, amd64), Linux (amd64, arm64), and Windows (amd64) — no separate install required.
14
+
15
+ ## Quick Start
16
+
17
+ ```python
18
+ from agent_runtime import Runtime, RunError
19
+
20
+ rt = Runtime()
21
+
22
+ @rt.tool("pricing.get_quote", version="v1")
23
+ def get_quote(sku: str, quantity: int) -> dict:
24
+ return {"unit_price": 9.99, "currency": "USD"}
25
+
26
+ try:
27
+ output = rt.run("./my_bundle.agent", inputs={"sku": "ABC-1", "quantity": 10})
28
+ print(output)
29
+ except RunError as e:
30
+ print(f"Flow failed: {e} (run_id={e.run_id})")
31
+ ```
32
+
33
+ ## Authoring Bundles
34
+
35
+ Bundles are directories with a `.agent` extension containing a declarative flow definition. See [FLOWS.md](https://github.com/levelplaneai/agent-runtime/blob/main/FLOWS.md) in the main repo for the full authoring guide.
36
+
37
+ ## API Reference
38
+
39
+ ### `Runtime(binary=None, env=None)`
40
+
41
+ Creates a runtime instance.
42
+
43
+ - `binary` — explicit path to the `agent-runtime` binary (optional)
44
+ - `env` — extra environment variables merged into the subprocess environment
45
+
46
+ ### `@rt.tool(name, version="v1")`
47
+
48
+ Decorator that registers a Python function as a tool callable by the workflow. The tool reference inside the bundle must match `name@version`.
49
+
50
+ ```python
51
+ @rt.tool("supplier_api.get_price", version="v1")
52
+ def get_price(item_code: str) -> dict:
53
+ return {"price": 42.0}
54
+
55
+ # Async tools are also supported
56
+ @rt.tool("data.fetch_record", version="v1")
57
+ async def fetch_record(record_id: str) -> dict:
58
+ ...
59
+ ```
60
+
61
+ ### `rt.run(bundle, inputs=None, on_event=None) -> dict`
62
+
63
+ Executes a bundle synchronously and returns the flow output as a dict.
64
+
65
+ ### `rt.arun(bundle, inputs=None, on_event=None) -> dict`
66
+
67
+ Async version of `run`. Use with `await` inside an async context.
68
+
69
+ ```python
70
+ result = await rt.arun("./bundle.agent", inputs={"query": "hello"})
71
+ ```
72
+
73
+ ### `rt.validate(bundle)`
74
+
75
+ Validates a bundle directory. Raises `RuntimeError` if the bundle is invalid.
76
+
77
+ ## File Inputs
78
+
79
+ Use `FileInput` to pass a local file as a flow input. The path is resolved to an absolute path automatically.
80
+
81
+ ```python
82
+ from agent_runtime import Runtime, FileInput
83
+
84
+ rt = Runtime()
85
+ output = rt.run("./ocr_bundle.agent", inputs={"document": FileInput("./invoice.pdf")})
86
+ ```
87
+
88
+ ## Streaming Events
89
+
90
+ Pass an `on_event` callback to receive `TraceEvent` objects as the workflow executes.
91
+
92
+ ```python
93
+ def on_event(event: TraceEvent) -> None:
94
+ print(f"[{event.event}] node={event.node} duration={event.duration_ms}ms")
95
+
96
+ rt.run("./bundle.agent", inputs={...}, on_event=on_event)
97
+ ```
98
+
99
+ Key `TraceEvent` fields:
100
+
101
+ | Field | Type | Description |
102
+ |---|---|---|
103
+ | `event` | `str` | Event type (e.g. `node.start`, `node.done`, `tool.call`) |
104
+ | `node` | `str` | Node name in the flow |
105
+ | `node_type` | `str` | Node type (e.g. `llm`, `tool`, `router`) |
106
+ | `tool` | `str` | Tool reference if a tool was called |
107
+ | `model` | `str` | Model name for LLM nodes |
108
+ | `input_tokens` | `int` | Tokens consumed |
109
+ | `output_tokens` | `int` | Tokens produced |
110
+ | `duration_ms` | `int` | Node execution time |
111
+ | `error` | `str` | Error message if the node failed |
112
+ | `output` | `dict` | Node output |
113
+
114
+ ## Traces & Debugging
115
+
116
+ ### Where traces go
117
+
118
+ Trace events are emitted by the runtime binary to stdout as newline-delimited JSON and streamed to you in real time via the `on_event` callback. There is no separate log file — if you don't attach a callback, events are silently consumed and discarded.
119
+
120
+ To capture a full trace for debugging, collect all events into a list:
121
+
122
+ ```python
123
+ from agent_runtime import Runtime, TraceEvent, RunError
124
+
125
+ rt = Runtime()
126
+ trace: list[TraceEvent] = []
127
+
128
+ try:
129
+ output = rt.run("./bundle.agent", inputs={...}, on_event=trace.append)
130
+ except RunError as e:
131
+ # Flow-level failure — the error message and run_id are on the exception.
132
+ # Check the trace for the node that produced the error.
133
+ failed = [ev for ev in trace if ev.error]
134
+ for ev in failed:
135
+ print(f"node={ev.node} error={ev.error}")
136
+ raise
137
+ ```
138
+
139
+ ### Event types
140
+
141
+ | Event | When it fires |
142
+ |---|---|
143
+ | `flow_start` | Flow begins executing |
144
+ | `flow_done` | Flow completed successfully |
145
+ | `node_start` | A node begins executing |
146
+ | `node_done` | A node finished (check `ev.error` for failure) |
147
+ | `tool_call` | The runtime is calling a registered tool |
148
+ | `tool_done` | Tool call returned |
149
+
150
+ ### Error channels
151
+
152
+ There are two ways a run can surface an error:
153
+
154
+ **Node-level** — a node fails but the flow may continue (e.g. a retry). Delivered as a `TraceEvent` with `event="node_done"` and a non-empty `error` field. The `attempt` and `max_retries` fields indicate retry state.
155
+
156
+ **Flow-level** — the flow terminates in an error state. The SDK raises `RunError` with the message and `run_id`. Check the collected trace to find which node caused it.
157
+
158
+ **Binary crash** — the `agent-runtime` process exits with a non-zero code (misconfigured bundle, missing env var, etc.). The SDK raises `RuntimeError` with the stderr output as the message. This is distinct from a flow error and does not produce a `RunError`.
159
+
160
+ ### Typical debug loop
161
+
162
+ 1. Collect the full trace with `on_event=trace.append`
163
+ 2. On `RunError`, filter `[ev for ev in trace if ev.error]` to find the failing node
164
+ 3. Inspect `ev.inputs`, `ev.args`, and `ev.output` on surrounding events to understand the data at that point
165
+ 4. Fix the bundle or tool, then re-run
166
+
167
+ ## Binary Resolution
168
+
169
+ The SDK locates the `agent-runtime` binary in this order:
170
+
171
+ 1. `binary` argument passed to `Runtime()`
172
+ 2. `AGENT_RUNTIME_BIN` environment variable
173
+ 3. Bundled platform binary (included in the package)
174
+ 4. `agent-runtime` on `PATH`
175
+
176
+ ## Development
177
+
178
+ ```bash
179
+ uv run pytest # run tests
180
+ uv run ruff check . # lint
181
+ ```
@@ -0,0 +1,4 @@
1
+ from ._runtime import Runtime
2
+ from ._types import FileInput, MissingAPIKeyError, RunError, TraceEvent
3
+
4
+ __all__ = ["Runtime", "FileInput", "MissingAPIKeyError", "RunError", "TraceEvent"]