wizardflow 0.7.0__tar.gz → 0.8.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.
Files changed (120) hide show
  1. {wizardflow-0.7.0 → wizardflow-0.8.0}/PKG-INFO +14 -7
  2. {wizardflow-0.7.0 → wizardflow-0.8.0}/README.md +13 -6
  3. {wizardflow-0.7.0 → wizardflow-0.8.0}/docs/cli.md +9 -5
  4. {wizardflow-0.7.0 → wizardflow-0.8.0}/docs/jsonl-file-format.md +4 -1
  5. wizardflow-0.8.0/docs/opentelemetry.md +446 -0
  6. {wizardflow-0.7.0 → wizardflow-0.8.0}/docs/recording.md +40 -3
  7. {wizardflow-0.7.0 → wizardflow-0.8.0}/pyproject.toml +1 -1
  8. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/__init__.py +33 -7
  9. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/404.html +2 -2
  10. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/__next.__PAGE__.txt +2 -2
  11. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/__next._full.txt +3 -3
  12. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/__next._head.txt +1 -1
  13. {wizardflow-0.7.0/src/wizardflow/_ui/why-wizardflow → wizardflow-0.8.0/src/wizardflow/_ui}/__next._index.txt +2 -2
  14. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/__next._tree.txt +2 -2
  15. wizardflow-0.7.0/src/wizardflow/_ui/_next/static/chunks/3fxdmyfsnxue6.js → wizardflow-0.8.0/src/wizardflow/_ui/_next/static/chunks/2_iu57vjc6ikq.js +6 -6
  16. wizardflow-0.7.0/src/wizardflow/_ui/_next/static/chunks/18clj6xsyhc_j.css → wizardflow-0.8.0/src/wizardflow/_ui/_next/static/chunks/301ajw92ycgkd.css +2 -2
  17. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_not-found/__next._full.txt +2 -2
  18. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_not-found/__next._head.txt +1 -1
  19. {wizardflow-0.7.0/src/wizardflow/_ui → wizardflow-0.8.0/src/wizardflow/_ui/_not-found}/__next._index.txt +2 -2
  20. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_not-found/__next._not-found/__PAGE__.txt +1 -1
  21. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_not-found/__next._not-found.txt +1 -1
  22. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_not-found/__next._tree.txt +2 -2
  23. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_not-found.html +2 -2
  24. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_not-found.txt +2 -2
  25. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/index.html +2 -2
  26. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/index.txt +3 -3
  27. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/sitemap.xml +1 -1
  28. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/why-wizardflow/__next._full.txt +3 -3
  29. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/why-wizardflow/__next._head.txt +1 -1
  30. {wizardflow-0.7.0/src/wizardflow/_ui/_not-found → wizardflow-0.8.0/src/wizardflow/_ui/why-wizardflow}/__next._index.txt +2 -2
  31. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/why-wizardflow/__next._tree.txt +2 -2
  32. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/why-wizardflow/__next.why-wizardflow/__PAGE__.txt +1 -1
  33. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/why-wizardflow/__next.why-wizardflow.txt +1 -1
  34. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/why-wizardflow.html +2 -2
  35. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/why-wizardflow.txt +3 -3
  36. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/cli.py +25 -4
  37. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/client.py +308 -33
  38. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/constants.py +3 -0
  39. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/otel.py +172 -75
  40. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/otel_file_exporter.py +12 -8
  41. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/otel_mapping.py +131 -24
  42. wizardflow-0.8.0/tests/helpers.py +74 -0
  43. {wizardflow-0.7.0 → wizardflow-0.8.0}/tests/test_cli.py +20 -2
  44. wizardflow-0.8.0/tests/test_langgraph.py +202 -0
  45. wizardflow-0.8.0/tests/test_node_lifecycle.py +144 -0
  46. {wizardflow-0.7.0 → wizardflow-0.8.0}/tests/test_otel.py +85 -17
  47. {wizardflow-0.7.0 → wizardflow-0.8.0}/tests/test_otel_file_exporter.py +14 -4
  48. wizardflow-0.8.0/tests/test_otel_integration.py +178 -0
  49. wizardflow-0.8.0/tests/test_persistence.py +106 -0
  50. wizardflow-0.8.0/tests/test_recording.py +348 -0
  51. wizardflow-0.8.0/tests/test_reinit.py +141 -0
  52. wizardflow-0.8.0/tests/test_rotation.py +122 -0
  53. wizardflow-0.8.0/tests/test_workflow.py +569 -0
  54. wizardflow-0.7.0/docs/opentelemetry.md +0 -302
  55. wizardflow-0.7.0/tests/test_trace.py +0 -1239
  56. {wizardflow-0.7.0 → wizardflow-0.8.0}/.gitignore +0 -0
  57. {wizardflow-0.7.0 → wizardflow-0.8.0}/CONTRIBUTING.md +0 -0
  58. {wizardflow-0.7.0 → wizardflow-0.8.0}/LICENSE +0 -0
  59. {wizardflow-0.7.0 → wizardflow-0.8.0}/assets/demo.gif +0 -0
  60. {wizardflow-0.7.0 → wizardflow-0.8.0}/examples/data_types.py +0 -0
  61. {wizardflow-0.7.0 → wizardflow-0.8.0}/examples/multibranch.html +0 -0
  62. {wizardflow-0.7.0 → wizardflow-0.8.0}/examples/multibranch.md +0 -0
  63. {wizardflow-0.7.0 → wizardflow-0.8.0}/examples/multibranch.py +0 -0
  64. {wizardflow-0.7.0 → wizardflow-0.8.0}/examples/quickstart.html +0 -0
  65. {wizardflow-0.7.0 → wizardflow-0.8.0}/examples/quickstart.md +0 -0
  66. {wizardflow-0.7.0 → wizardflow-0.8.0}/examples/quickstart.py +0 -0
  67. {wizardflow-0.7.0 → wizardflow-0.8.0}/scripts/build_ui.py +0 -0
  68. {wizardflow-0.7.0 → wizardflow-0.8.0}/scripts/live_trace_demo.py +0 -0
  69. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_render.py +0 -0
  70. {wizardflow-0.7.0/src/wizardflow/_ui/_next/static/H81QsKAgLXQMK2H6vyBjb → wizardflow-0.8.0/src/wizardflow/_ui/_next/static/1QfoA382k0nvObP14Huhr}/_buildManifest.js +0 -0
  71. {wizardflow-0.7.0/src/wizardflow/_ui/_next/static/H81QsKAgLXQMK2H6vyBjb → wizardflow-0.8.0/src/wizardflow/_ui/_next/static/1QfoA382k0nvObP14Huhr}/_clientMiddlewareManifest.js +0 -0
  72. {wizardflow-0.7.0/src/wizardflow/_ui/_next/static/H81QsKAgLXQMK2H6vyBjb → wizardflow-0.8.0/src/wizardflow/_ui/_next/static/1QfoA382k0nvObP14Huhr}/_ssgManifest.js +0 -0
  73. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/05-c3ty_6dwfk.js +0 -0
  74. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/09s72r58ijxwx.js +0 -0
  75. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/0cz1d0mv5g_q7.js +0 -0
  76. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/0d1yav018wi6n.js +0 -0
  77. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/0fizjutis9uvx.js +0 -0
  78. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/14a18doinx71t.css +0 -0
  79. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/14mrh2-p_w84d.js +0 -0
  80. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/1_way7swvumpv.js +0 -0
  81. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/1diz-5jfxjm5x.js +0 -0
  82. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/1por0fhggxwcm.js +0 -0
  83. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/2-j1b74l3lxxu.css +0 -0
  84. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/24c18qa28ilul.css +0 -0
  85. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/27jktro2p5rq9.js +0 -0
  86. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/2dclsx_n3obic.js +0 -0
  87. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/2gj5bmeov-r8f.js +0 -0
  88. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/2l6srvxdnb-io.js +0 -0
  89. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/310vm2bl3xxpt.js +0 -0
  90. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/32c7h_m2amh5m.js +0 -0
  91. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/352yh6c3r6-0k.js +0 -0
  92. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/3n7dm2ojtyzwn.js +0 -0
  93. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/3q-c23s8gv3du.js +0 -0
  94. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/3rdqn8rx95pw7.js +0 -0
  95. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/414c1-tn-1aef.js +0 -0
  96. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/43x_68q2b6gcs.js +0 -0
  97. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/chunks/turbopack-2fblmukzx7kws.js +0 -0
  98. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/media/4fa387ec64143e14-s.2tuy5pz7dlieh.woff2 +0 -0
  99. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/media/53b9e256198e5412-s.390ncx5urfkfu.woff2 +0 -0
  100. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/media/5ce348bf30bf5439-s.31988l_ccedte.woff2 +0 -0
  101. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/media/6306c77e7c8268e4-s.2dbetqa9o8jxf.woff2 +0 -0
  102. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/media/7178b3e590c64307-s.21jp631_3pja2.woff2 +0 -0
  103. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/media/797e433ab948586e-s.p.0r6juujl39pe6.woff2 +0 -0
  104. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/media/7d817b4c03b0c5f1-s.1uyisp29ctx0d.woff2 +0 -0
  105. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/media/8a480f0b521d4e75-s.1qq4vpdcun5oj.woff2 +0 -0
  106. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/media/bbc41e54d2fcbd21-s.1rgnod-3esatf.woff2 +0 -0
  107. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/media/caa3a2e1cccd8315-s.p.0wgildi0cnwt9.woff2 +0 -0
  108. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/media/fef07dbb0973bf53-s.3p2_lha1f2xer.woff2 +0 -0
  109. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/_next/static/media/icon.09qublg69ek7b.svg +0 -0
  110. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/icon.svg +0 -0
  111. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/opengraph-image +0 -0
  112. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/_ui/robots.txt +0 -0
  113. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/html.py +0 -0
  114. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/markdown.py +0 -0
  115. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/py.typed +0 -0
  116. {wizardflow-0.7.0 → wizardflow-0.8.0}/src/wizardflow/reader.py +0 -0
  117. {wizardflow-0.7.0 → wizardflow-0.8.0}/tests/conftest.py +0 -0
  118. {wizardflow-0.7.0 → wizardflow-0.8.0}/tests/test_html.py +0 -0
  119. {wizardflow-0.7.0 → wizardflow-0.8.0}/tests/test_markdown.py +0 -0
  120. {wizardflow-0.7.0 → wizardflow-0.8.0}/tests/test_reader.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: wizardflow
3
- Version: 0.7.0
3
+ Version: 0.8.0
4
4
  Summary: Python SDK for recording agent flows into the WizardFlow / AgentTrace file format.
5
5
  Project-URL: Homepage, https://getwizardflow.com
6
6
  Project-URL: Documentation, https://getwizardflow.com
@@ -145,17 +145,22 @@ trace = wizardflow.init(
145
145
  name="my-agent",
146
146
  otel=True,
147
147
  otel_endpoint="http://localhost:4318/v1/traces",
148
- otel_trace_scope="message",
148
+ otel_workflow_name="answer",
149
149
  )
150
150
 
151
- with trace.node("msg-1", "generator", kind="llm") as node:
152
- node.log_input(input_value)
153
- node.log_output(output_value)
151
+ with trace.workflow() as run: # one workflow = one OTel trace
152
+ run.set_info(otel_attributes={"session.id": chat_id})
153
+ with run.node("generator", kind="llm") as node:
154
+ node.log_input(input_value)
155
+ node.log_output(output_value)
154
156
 
155
- trace.end_message("msg-1")
156
157
  trace.close_otel()
157
158
  ```
158
159
 
160
+ `otel_attributes` sets exact keys on the workflow's root span — e.g.
161
+ `session.id` groups traces into Phoenix sessions, `langfuse.session.id` into
162
+ Langfuse sessions.
163
+
159
164
  Generic logs can optionally choose an exact application-owned span attribute
160
165
  without changing their JSONL/UI label:
161
166
 
@@ -163,7 +168,9 @@ without changing their JSONL/UI label:
163
168
  node.log("quality", 0.92, otel_attribute="app.response.quality")
164
169
  ```
165
170
 
166
- Content export is privacy-conscious and disabled by default. See the
171
+ Content export is enabled by default when OTel export is enabled, with
172
+ `otel_include_content=False` and CLI `--no-include-content` available when the
173
+ receiver should only get metadata. See the
167
174
  [OpenTelemetry guide](https://github.com/lkleonk/wizardflow/blob/main/sdk/python/docs/opentelemetry.md)
168
175
  for provider ownership, GenAI mappings, content controls, graph events, and
169
176
  independent JSONL/OTel lifecycles. Existing artifacts can be exported later:
@@ -98,17 +98,22 @@ trace = wizardflow.init(
98
98
  name="my-agent",
99
99
  otel=True,
100
100
  otel_endpoint="http://localhost:4318/v1/traces",
101
- otel_trace_scope="message",
101
+ otel_workflow_name="answer",
102
102
  )
103
103
 
104
- with trace.node("msg-1", "generator", kind="llm") as node:
105
- node.log_input(input_value)
106
- node.log_output(output_value)
104
+ with trace.workflow() as run: # one workflow = one OTel trace
105
+ run.set_info(otel_attributes={"session.id": chat_id})
106
+ with run.node("generator", kind="llm") as node:
107
+ node.log_input(input_value)
108
+ node.log_output(output_value)
107
109
 
108
- trace.end_message("msg-1")
109
110
  trace.close_otel()
110
111
  ```
111
112
 
113
+ `otel_attributes` sets exact keys on the workflow's root span — e.g.
114
+ `session.id` groups traces into Phoenix sessions, `langfuse.session.id` into
115
+ Langfuse sessions.
116
+
112
117
  Generic logs can optionally choose an exact application-owned span attribute
113
118
  without changing their JSONL/UI label:
114
119
 
@@ -116,7 +121,9 @@ without changing their JSONL/UI label:
116
121
  node.log("quality", 0.92, otel_attribute="app.response.quality")
117
122
  ```
118
123
 
119
- Content export is privacy-conscious and disabled by default. See the
124
+ Content export is enabled by default when OTel export is enabled, with
125
+ `otel_include_content=False` and CLI `--no-include-content` available when the
126
+ receiver should only get metadata. See the
120
127
  [OpenTelemetry guide](https://github.com/lkleonk/wizardflow/blob/main/sdk/python/docs/opentelemetry.md)
121
128
  for provider ownership, GenAI mappings, content controls, graph events, and
122
129
  independent JSONL/OTel lifecycles. Existing artifacts can be exported later:
@@ -84,20 +84,24 @@ does not combine an entire rotation chain.
84
84
 
85
85
  ```bash
86
86
  wizardflow otel export run.jsonl --endpoint http://localhost:4318/v1/traces
87
- wizardflow otel export run.jsonl --trace-scope message
87
+ wizardflow otel export run.jsonl --workflow-name consultation
88
+ wizardflow otel export run.jsonl --trace-scope recording
88
89
  ```
89
90
 
90
91
  This projects an existing artifact through OTLP/HTTP using the same semantic
91
92
  mapping as live export. It creates fresh OTel trace IDs and never modifies the
92
93
  source file. By default it discovers and exports the complete rotated
93
- part-chain and creates one `wizardflow.run` trace; `--trace-scope message`
94
- creates one `wizardflow.message` trace per message.
94
+ part-chain and creates one trace per message, rooted at an `invoke_workflow`
95
+ span; `--trace-scope recording` creates one `wizardflow.run` trace for the
96
+ whole chain. Live `otel_attributes` are not stored in JSONL, so exported roots
97
+ do not carry them.
95
98
 
96
99
  | Option | Default | Meaning |
97
100
  | --- | --- | --- |
98
101
  | `--endpoint` | OTel environment | OTLP/HTTP traces endpoint |
99
- | `--trace-scope` | `recording` | `recording` or `message` trace boundaries |
100
- | `--include-content` | off | Export bounded input, output, and structured log content |
102
+ | `--trace-scope` | `workflow` | `workflow` (one trace per message) or `recording` trace boundaries |
103
+ | `--workflow-name` | none | Stable `gen_ai.workflow.name` for workflow roots; match the live `otel_workflow_name` |
104
+ | `--include-content` / `--no-include-content` | on | Export or omit bounded input, output, and structured log content |
101
105
  | `--content-max-bytes` | `16_384` | Maximum bytes for each exported content value |
102
106
  | `--export-graph` | off | Add the WizardFlow graph event to each root |
103
107
  | `--graph-max-bytes` | `65_536` | Maximum full graph-event content size |
@@ -127,13 +127,16 @@ Explicit keys may extend or override semantic mappings. The structural identity
127
127
  keys `wizardflow.node.id`, `wizardflow.node.kind`, `wizardflow.message.id`, and
128
128
  `wizardflow.trace.name` are protected.
129
129
 
130
+ On an `input` or `output` semantic payload, `otelAttribute` is additive: the
131
+ semantic projection is kept and the value is also exported under that key.
132
+
130
133
  `exportToJsonl` is not stored: a record excluded from JSONL is absent.
131
134
 
132
135
  ## Source-of-truth rules
133
136
 
134
137
  - JSON-compatible complex values remain intact.
135
138
  - JSONL is transport-neutral by default; `otelAttribute` is an optional explicit
136
- projection hint for generic logs.
139
+ projection hint for generic logs and for input/output payloads.
137
140
  - Exporters, rather than the writer, normalize values for their transport.
138
141
  - Content truncation for OTel never mutates the JSONL value.
139
142
  - Generic labels do not imply semantic meaning.
@@ -0,0 +1,446 @@
1
+ # OpenTelemetry export
2
+
3
+ WizardFlow JSONL is the durable, transport-neutral source of truth.
4
+ OpenTelemetry is an optional projection of the same run for OTLP-compatible
5
+ backends such as Phoenix and Langfuse.
6
+
7
+ WizardFlow emits spans through the traces signal. It does not emit the OTel
8
+ Logs signal or duplicate OpenInference span attributes. A private provider uses
9
+ the OpenInference project resource attribute for backend grouping.
10
+
11
+ Existing JSONL artifacts can also be projected later with the offline exporter.
12
+
13
+ ## Installation
14
+
15
+ The base `wizardflow` package remains dependency-free. Install OTel packages
16
+ directly when enabling export:
17
+
18
+ ```bash
19
+ pip install opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp-proto-http
20
+ ```
21
+
22
+ ## Export an existing JSONL artifact
23
+
24
+ ```bash
25
+ wizardflow otel export run.jsonl \
26
+ --endpoint http://localhost:4318/v1/traces \
27
+ --workflow-name consultation
28
+ ```
29
+
30
+ The command discovers a rotated part-chain even when given a middle part and
31
+ exports all messages in part order. Use `--current-part-only` to export only
32
+ the named file. Input files are never modified.
33
+
34
+ Offline export creates fresh OTel trace IDs; JSONL cannot reconstruct live OTel
35
+ trace IDs or parent contexts. `--trace-scope workflow` (the default) creates one
36
+ new trace per message, rooted at an `invoke_workflow` span built exactly like
37
+ the live one; pass `--workflow-name` to match a live `otel_workflow_name`.
38
+ `--trace-scope recording` creates one new trace rooted at `wizardflow.run`. Both
39
+ modes preserve recorded node timestamps and use the same semantic mapper as
40
+ live export. Application `otel_attributes` are OTel-only and not stored in
41
+ JSONL, so offline roots do not carry them.
42
+
43
+ Content export is enabled by default so the receiving UI shows useful inputs,
44
+ outputs, and structured logs on the first export. Graph export remains opt-in:
45
+
46
+ ```bash
47
+ wizardflow otel export run.jsonl --export-graph
48
+ ```
49
+
50
+ The endpoint may instead come from `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`, or
51
+ from `OTEL_EXPORTER_OTLP_ENDPOINT` with `/v1/traces` appended. Standard OTel
52
+ header environment variables configure authentication. The offline command
53
+ always owns and shuts down a private provider; it never changes the global
54
+ tracer provider.
55
+
56
+ ## Configuration
57
+
58
+ ```python
59
+ import wizardflow
60
+
61
+ trace = wizardflow.init(
62
+ nodes=["classifier", "advisor"],
63
+ name="student-advisor", # project (with otel_endpoint)
64
+ otel=True,
65
+ otel_endpoint="http://localhost:4318/v1/traces",
66
+ otel_trace_scope="workflow", # default
67
+ otel_workflow_name="consultation", # stable workflow type, optional
68
+ otel_attributes={"deployment.environment": "prod"}, # on every root
69
+ otel_include_content=True, # default; set False to omit recorded content
70
+ otel_content_max_bytes=16_384,
71
+ export_graph_to_otel=False,
72
+ )
73
+
74
+ with trace.workflow() as run:
75
+ run.set_info(
76
+ title="Degree consultation",
77
+ otel_attributes={"session.id": chat_id, "user.id": user_id},
78
+ )
79
+ with run.node("classifier") as node:
80
+ node.log_input(question)
81
+ ```
82
+
83
+ How WizardFlow concepts map onto what OTel backends show:
84
+
85
+ | WizardFlow | OTel / backends |
86
+ | --- | --- |
87
+ | recording `name` | project (`openinference.project.name` resource, with `otel_endpoint`) |
88
+ | `otel_workflow_name` | workflow type (`gen_ai.workflow.name`) |
89
+ | message = one workflow execution | one trace, rooted at an `invoke_workflow` span |
90
+ | node execution | one span under that root |
91
+ | `otel_attributes` such as `session.id` | session / user grouping of traces |
92
+
93
+ Output modes are independent:
94
+
95
+ | `jsonl` | `otel` | Result |
96
+ | --- | --- | --- |
97
+ | `True` | `False` | JSONL only |
98
+ | `True` | `True` | JSONL and OTel |
99
+ | `False` | `True` | OTel only |
100
+ | `False` | `False` | In-memory recording only |
101
+
102
+ ## Provider ownership
103
+
104
+ Without `otel_endpoint`, WizardFlow obtains a tracer from the application's
105
+ global provider. It never calls `set_tracer_provider()`, adds processors to the
106
+ global provider, or shuts that provider down.
107
+
108
+ With an endpoint, WizardFlow creates a private SDK provider, batch processor,
109
+ and OTLP/HTTP exporter. This isolates WizardFlow configuration from the host
110
+ application. If `name` is set, WizardFlow also uses it as the OpenInference
111
+ project resource name. Backends such as Phoenix therefore group successive
112
+ WizardFlow traces under that project instead of placing them in `default`.
113
+
114
+ Without an endpoint, the application owns the global provider and its resource
115
+ configuration. A resource is fixed per provider, so `name` then does **not**
116
+ become the project: set the project where you configure OTel, for example
117
+ `phoenix.otel.register(project_name="student-advisor")`. Langfuse ignores the
118
+ resource either way; its project comes from the API key.
119
+
120
+ Finish OTel output explicitly:
121
+
122
+ ```python
123
+ trace.close_otel()
124
+ ```
125
+
126
+ `close_otel()` is idempotent. It ends any active WizardFlow roots, flushes and
127
+ shuts down only a WizardFlow-owned private provider, and leaves JSONL recording
128
+ completely unaffected. After closing, `trace.reinit(otel=True)` can create a
129
+ fresh private provider and trace.
130
+
131
+ ## Trace scope, shape, and timestamps
132
+
133
+ A trace is the collection of spans that share one trace ID. `otel_trace_scope`
134
+ controls where WizardFlow draws that boundary:
135
+
136
+ | Value | Trace boundary |
137
+ | --- | --- |
138
+ | `"workflow"` (default) | One independent trace per workflow execution (WizardFlow message), rooted at an `invoke_workflow` span |
139
+ | `"recording"` | One trace from initialization or OTel reinitialization until the next reinitialization or `close_otel()` |
140
+
141
+ Workflow scope is the standard request-oriented model used by Phoenix,
142
+ Langfuse, and the GenAI semantic conventions, and the only scope that supports
143
+ session grouping. Recording scope is a specialized whole-recording view: its
144
+ root stays open until `close_otel()` or process exit, and backends show it as
145
+ incomplete until then.
146
+
147
+ In workflow scope, every workflow execution maps to one trace. The root follows
148
+ the OTel GenAI `invoke_workflow` span convention (currently marked
149
+ Development):
150
+
151
+ ```text
152
+ invoke_workflow consultation INTERNAL root span
153
+ ├── classifier node span
154
+ └── advisor node span
155
+ ```
156
+
157
+ The root span carries:
158
+
159
+ ```text
160
+ gen_ai.operation.name = "invoke_workflow"
161
+ gen_ai.workflow.name = "consultation" # only with otel_workflow_name
162
+ wizardflow.message.id = <generated or caller-provided message id>
163
+ wizardflow.message.title = "Degree consultation" # when a title is supplied
164
+ wizardflow.message.metadata = <deterministic JSON> # when meta is supplied
165
+ <otel_attributes> # init-level, then per-workflow
166
+ ```
167
+
168
+ The `invoke_workflow` span is the root operation, not a separate trace object.
169
+ Without `otel_workflow_name` it is named just `invoke_workflow` and omits
170
+ `gen_ai.workflow.name`; WizardFlow never invents a workflow name. The workflow
171
+ name is a stable, low-cardinality type, configured once. The per-execution
172
+ title never renames the root.
173
+
174
+ `trace.workflow()` starts the root when the block begins and makes it the
175
+ current span, so auto-instrumented calls inside the block (HTTP clients, model
176
+ SDKs) are parented under it. Leaving the block ends it. If the block raises,
177
+ the root records the exception, sets `error.type`, and gets error status; the
178
+ exception still propagates.
179
+
180
+ The lower-level `message_id` / `end_message()` API produces the same shape: the
181
+ root is created lazily from the first node's start time and ended by
182
+ `end_message()`. Ending a message that never ran a node still emits a
183
+ zero-child root. Overlapping message IDs remain independent traces, each with
184
+ its own root and context. `close_otel()` ends roots that were never finished
185
+ with unset status, since no failure was observed.
186
+
187
+ In recording scope, one active WizardFlow OTel recording maps to one trace
188
+ rooted at `wizardflow.run`, and `trace.workflow()` does not create extra roots:
189
+
190
+ ```text
191
+ wizardflow.run
192
+ ├── researcher wizardflow.message.id=m1
193
+ ├── model wizardflow.message.id=m1
194
+ └── model wizardflow.message.id=m2
195
+ ```
196
+
197
+ Every node span carries:
198
+
199
+ ```text
200
+ wizardflow.message.id
201
+ wizardflow.node.id
202
+ wizardflow.node.kind
203
+ ```
204
+
205
+ Node spans use the resolved WizardFlow `timestamp` and `endTimestamp`, rather
206
+ than the time at which an exporter happens to process them. Workflow scope and
207
+ recording scope only change OTel trace boundaries; JSONL files and rotation are
208
+ unaffected.
209
+
210
+ ### Span granularity
211
+
212
+ WizardFlow uses one span for each node execution. This is similar to the
213
+ operation-oriented model used by GenAI tracing systems such as
214
+ Phoenix/OpenInference, where an agent invocation, model call, retrieval, or
215
+ tool execution is represented by a span. The boundaries are not necessarily
216
+ identical: WizardFlow can only describe the node execution it records.
217
+
218
+ When one node execution represents one logical operation, the resulting span
219
+ has the expected operation-level granularity. When a node internally performs
220
+ several model or tool calls, WizardFlow still exports one node span; those
221
+ internal calls require their own instrumentation to appear as child spans.
222
+ This is a difference in detail, not an OTLP compatibility issue. The receiving
223
+ backend can still ingest and display the WizardFlow spans normally.
224
+
225
+ ## Application attributes on the workflow root
226
+
227
+ `otel_attributes` sets exact, application-chosen keys on workflow root spans.
228
+ It is the counterpart of `log(otel_attribute=...)` for the execution as a
229
+ whole, and the way to make traces groupable by backends:
230
+
231
+ | Purpose | Phoenix / OpenInference | Langfuse | GenAI semconv |
232
+ | --- | --- | --- | --- |
233
+ | Session / conversation | `session.id` | `langfuse.session.id` (or `session.id`) | `gen_ai.conversation.id` |
234
+ | User | `user.id` | `langfuse.user.id` (or `user.id`) | — |
235
+
236
+ ```python
237
+ trace = wizardflow.init(..., otel_attributes={"deployment.environment": "prod"})
238
+
239
+ with trace.workflow() as run:
240
+ run.set_info(otel_attributes={"session.id": chat_id, "user.id": user_id})
241
+ ...
242
+
243
+ # Low-level form:
244
+ trace.end_message(message_id, otel_attributes={"session.id": chat_id})
245
+ ```
246
+
247
+ - `init()` / `reinit()` values apply to every workflow root started afterwards
248
+ (in recording scope, to the recording root).
249
+ - `set_info()` / `end_message()` values apply to that workflow's root only and
250
+ override init-level values for the same key. Repeated `set_info()` calls
251
+ merge.
252
+ - Keys are used exactly, with the same rules as `otel_attribute` (non-empty, no
253
+ surrounding whitespace or control characters). The keys WizardFlow sets on
254
+ the root are protected: `gen_ai.operation.name`, `gen_ai.workflow.name`,
255
+ `wizardflow.message.id`, `wizardflow.message.title`,
256
+ `wizardflow.message.metadata`, plus the node identity keys.
257
+ - Values must be `str`, `bool`, `int`, `float`, or a non-empty list of one of
258
+ those types. Invalid entries raise, or are dropped with a warning when
259
+ `silent=True`.
260
+ - They are identifiers the application chose, so they are exported even with
261
+ `otel_include_content=False`.
262
+ - They are OTel-only: JSONL never stores them, and the offline exporter cannot
263
+ reproduce them.
264
+ - In recording scope there is no per-workflow root. Per-workflow
265
+ `otel_attributes` are ignored with one warning rather than attached to the
266
+ recording root, because backends treat session and user as properties of the
267
+ whole trace.
268
+ - They are set on the root span only. Langfuse notes that filtering *spans* by
269
+ these attributes requires them on every span; session grouping of traces
270
+ works from the root.
271
+
272
+ `meta` stays separate: it is exported as one bounded JSON value,
273
+ `wizardflow.message.metadata`, and its keys are never turned into attribute
274
+ names.
275
+
276
+ ## GenAI semantic projection
277
+
278
+ Use an execution kind only when it accurately describes the node:
279
+
280
+ ```python
281
+ with trace.node(message_id, "model", kind="llm") as node:
282
+ node.log_input(messages)
283
+ node.log_model_parameters(model="gpt-5", temperature=0.7)
284
+ node.log_output(response)
285
+ node.log_usage(input_tokens=120, output_tokens=30)
286
+ ```
287
+
288
+ Current conservative mapping:
289
+
290
+ | Kind | Standard projection |
291
+ | --- | --- |
292
+ | generic | Custom `wizardflow.*` attributes only |
293
+ | `llm` | GenAI content, compatible request parameters, and usage; no guessed operation name |
294
+ | `agent` | `gen_ai.operation.name=invoke_agent`, agent name, compatible content/metadata |
295
+ | `tool` | `gen_ai.operation.name=execute_tool`, tool name, valid argument/result objects |
296
+ | `retriever` | `gen_ai.operation.name=retrieval`, string query and valid document-list content |
297
+ | `embedding` | `gen_ai.operation.name=embeddings`, compatible model and input-token metadata |
298
+ | `reranker` | Custom attributes; no current standardized operation is invented |
299
+
300
+ `log_input()` and `log_output()` do not create GenAI fields on a generic node.
301
+ The mapper needs both a compatible node kind and an explicit semantic record.
302
+
303
+ Recognized model parameters map to compatible `gen_ai.request.*` attributes.
304
+ Unknown or unsupported parameters remain readable under
305
+ `wizardflow.model_parameter.*`.
306
+
307
+ ## Generic payloads
308
+
309
+ Arbitrary scalar payloads (generic `log()` records) export by default as custom
310
+ span attributes. They are named `payload`, not `log`, because OTel "logs" are
311
+ the separate Logs signal:
312
+
313
+ ```text
314
+ wizardflow.payload.confidence = 0.91
315
+ wizardflow.payload.retrieval = "..."
316
+ ```
317
+
318
+ Duplicate normalized labels preserve the first unsuffixed:
319
+
320
+ ```text
321
+ wizardflow.payload.retrieval
322
+ wizardflow.payload.retrieval.1
323
+ wizardflow.payload.retrieval.2
324
+ ```
325
+
326
+ For an exact application-owned attribute key, generic `log()` accepts
327
+ `otel_attribute`:
328
+
329
+ ```python
330
+ node.log(
331
+ "retrieval_results",
332
+ documents,
333
+ otel_attribute="app.main.retrieval",
334
+ )
335
+ ```
336
+
337
+ The developer-facing JSONL/UI label remains `retrieval_results`, while the span
338
+ attribute is exactly `app.main.retrieval`. The override is persisted as
339
+ `otelAttribute`, so live and offline export agree. Explicit keys are not
340
+ normalized. They must be non-empty, contain no surrounding whitespace or
341
+ control characters. Explicit values are applied after automatic mappings, so
342
+ they may intentionally extend or override `gen_ai.*` and WizardFlow attributes.
343
+ Only `wizardflow.node.id`, `wizardflow.node.kind`, `wizardflow.message.id`, and
344
+ `wizardflow.trace.name` are protected because changing them would make the span
345
+ contradict its recorded execution. If the same explicit key is logged more than
346
+ once during one node execution, the last value wins and export emits a warning.
347
+
348
+ This option does not bypass content controls or truncation. Prefer the semantic
349
+ logging helpers for inputs, outputs, usage, model parameters, and compatible
350
+ retrieval data; the custom key is an escape hatch for application-specific
351
+ attributes.
352
+
353
+ ### Exact keys for inputs and outputs
354
+
355
+ `log_input()` and `log_output()` accept `otel_attribute` too. There it is
356
+ **additive**: the automatic projection (`gen_ai.input.messages`, tool
357
+ arguments, and so on) is kept, and the same value is also exported under the
358
+ exact key. The record stays one JSONL payload, with `otelAttribute` persisted
359
+ so offline export agrees:
360
+
361
+ ```python
362
+ node.log_input(question, otel_attribute="input.value")
363
+ node.log_output(answer, otel_attribute="output.value")
364
+ ```
365
+
366
+ This is useful for backends that read other keys than `gen_ai.*`. Phoenix, for
367
+ example, fills its span Input/Output panels from the OpenInference keys
368
+ `input.value` / `output.value`. Because inputs and outputs are content, the
369
+ extra key follows `otel_include_content` (even for plain strings) and
370
+ `otel_content_max_bytes`. The same key rules, protected keys, and
371
+ last-value-wins warning as for generic logs apply.
372
+
373
+ WizardFlow never guesses GenAI semantics from a generic label. A record with
374
+ `export_to_otel=False` is never exported.
375
+
376
+ ## Content privacy and size bounds
377
+
378
+ Content export is enabled by default once OTel export itself is enabled. This
379
+ can include prompts, responses, retrieved documents, and tool results. Use
380
+ `otel_include_content=False` for live export or `--no-include-content` for the
381
+ CLI when the receiving system should only receive metadata. With content
382
+ disabled:
383
+
384
+ - semantic input/output is omitted;
385
+ - structured generic logs are omitted;
386
+ - scalar generic logs still export;
387
+ - usage and compatible model parameters still export as metadata;
388
+ - the workflow root keeps its title, but omits the `meta` JSON
389
+ (`wizardflow.message.metadata`);
390
+ - `otel_attributes` still export, since the application chose them.
391
+
392
+ Only export content to a receiving system appropriate for the data. Exported
393
+ content is deterministically serialized and bounded by
394
+ `otel_content_max_bytes`, measured as UTF-8 bytes. JSONL always retains the
395
+ original untruncated value.
396
+
397
+ Strings remain text. Other JSON-compatible input/output values are serialized
398
+ as text content without guessing that arbitrary object keys represent chat
399
+ messages. For compatible LLM and agent spans, the exporter wraps that text in
400
+ the official GenAI input/output message structure.
401
+
402
+ ## Optional graph event
403
+
404
+ ```python
405
+ trace = wizardflow.init(
406
+ nodes=[...],
407
+ edges=[...],
408
+ otel=True,
409
+ export_graph_to_otel=True,
410
+ )
411
+ ```
412
+
413
+ The declared graph is emitted once on each new root as a
414
+ `wizardflow.graph` span event. Nodes and edges are canonical JSON strings with
415
+ counts. Oversized graphs omit the full content and retain counts, byte size, and
416
+ a stable SHA-256 hash.
417
+
418
+ Graph export is off by default because topology can be sensitive or large. The
419
+ event uses the traces signal; it is not an OTel log record.
420
+
421
+ ## Independent reinitialization
422
+
423
+ ```python
424
+ trace.reinit(jsonl=True, otel=False) # retain the current OTel trace
425
+ trace.reinit(jsonl=False, otel=True) # retain the current JSONL run
426
+ trace.reinit() # start both anew
427
+ trace.reinit(otel_attributes={"deployment.environment": "staging"})
428
+ ```
429
+
430
+ In workflow scope, reinitialization changes the configuration (trace name,
431
+ init-level `otel_attributes`) used for workflows that start afterwards.
432
+ Already-open workflows keep the root and context captured when they began and
433
+ may finish normally. In recording scope, an OTel reinitialization ends the
434
+ current run root and starts a new trace; already-started node spans retain the
435
+ trace context captured when they began.
436
+
437
+ JSONL part/run boundaries cannot reconstruct these independently chosen live
438
+ OTel boundaries. The offline exporter therefore creates a fresh projection
439
+ using its explicit `--trace-scope` while sharing the live record-to-attribute
440
+ mapper.
441
+
442
+ ## Convention references
443
+
444
+ - [OTel GenAI spans](https://github.com/open-telemetry/semantic-conventions-genai/blob/main/docs/gen-ai/gen-ai-spans.md)
445
+ - [OTel GenAI agent spans](https://github.com/open-telemetry/semantic-conventions-genai/blob/main/docs/gen-ai/gen-ai-agent-spans.md)
446
+ - [OTel GenAI attribute registry](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/registry/attributes/gen-ai.md)
@@ -65,7 +65,31 @@ ignored. Exceptions raised by the application itself, including inside
65
65
 
66
66
  ## Messages and node executions
67
67
 
68
- A message is one unit of work, usually one user turn through the graph. Its ID
68
+ A message is one unit of work, usually one user turn through the graph — one
69
+ workflow execution. The simplest way to record one is the workflow context
70
+ manager, which generates the message ID and ends the message when the block
71
+ exits:
72
+
73
+ ```python
74
+ with trace.workflow() as run:
75
+ run.set_info(title="Degree consultation", meta={"language": "de"})
76
+
77
+ with run.node("classifier") as node:
78
+ node.log_input(question)
79
+ node.log_output("degree_question")
80
+
81
+ with run.node("advisor") as node:
82
+ node.log_output(answer)
83
+ ```
84
+
85
+ `run.message_id` exposes the generated ID for correlation. `set_info()` may be
86
+ called any number of times inside the block: a `title` replaces the previous
87
+ one, `meta` and `otel_attributes` merge. Leaving the block is the completion
88
+ signal — also when the body raises, in which case the message is still written
89
+ and the exception propagates. Workflows cannot be nested in the same execution
90
+ context; separate threads and asyncio tasks each run their own.
91
+
92
+ When your integration already owns an execution ID, pass it yourself. The ID
69
93
  must be unique until `end_message()` completes it. A fresh UUID is a good
70
94
  default; do not use a long-lived session or user ID as the message ID.
71
95
 
@@ -168,7 +192,7 @@ context manager when exact execution boundaries matter.
168
192
 
169
193
  ### Custom OpenTelemetry attribute key
170
194
 
171
- Generic logs normally export as `wizardflow.log.<normalized_label>`. When an
195
+ Generic payloads normally export as `wizardflow.payload.<normalized_label>`. When an
172
196
  application needs an exact, application-owned OTel key, keep the readable trace
173
197
  label and set the export key separately:
174
198
 
@@ -188,6 +212,14 @@ WizardFlow mappings. Only the structural identity keys `wizardflow.node.id`,
188
212
  protected. Prefer `log_input()`, `log_output()`, `log_usage()`, and
189
213
  `log_model_parameters()` whenever the data has one of those known meanings.
190
214
 
215
+ `log_input()` and `log_output()` also accept `otel_attribute`. For them it is
216
+ additive — the value keeps its automatic `gen_ai.*` mapping and is additionally
217
+ exported under your key, without a second JSONL payload:
218
+
219
+ ```python
220
+ node.log_output(answer, otel_attribute="output.value")
221
+ ```
222
+
191
223
  ## Selecting outputs per record
192
224
 
193
225
  Every logging method supports explicit output selection:
@@ -219,7 +251,12 @@ trace.end_message(
219
251
  ```
220
252
 
221
253
  Keep message metadata flat and scalar. Large or structured values belong in
222
- node payloads.
254
+ node payloads. Inside `trace.workflow()`, supply the same values with
255
+ `run.set_info(title=..., meta=...)`.
256
+
257
+ Both forms also accept `otel_attributes` — exact OTel keys for the workflow's
258
+ root span, such as `session.id` or `user.id`. They are OTel-only and never
259
+ written to JSONL; see [opentelemetry.md](opentelemetry.md#application-attributes-on-the-workflow-root).
223
260
 
224
261
  ## LangGraph topology
225
262
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "wizardflow"
7
- version = "0.7.0"
7
+ version = "0.8.0"
8
8
  description = "Python SDK for recording agent flows into the WizardFlow / AgentTrace file format."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"