traceAI-agentscope 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,87 @@
1
+ *.py[cod]
2
+
3
+ # C extensions
4
+ *.so
5
+
6
+ # IDEs
7
+ .idea/
8
+ .vscode/
9
+
10
+ # Packages
11
+ *.egg
12
+ *.egg-info
13
+ .eggs/
14
+ # build
15
+ parts
16
+ bin
17
+ var
18
+ sdist
19
+ dist
20
+ develop-eggs
21
+ .installed.cfg
22
+ lib
23
+ lib64
24
+
25
+ # Installer logs
26
+ pip-log.txt
27
+
28
+ # Unit test / coverage reports
29
+ .coverage
30
+ .tox
31
+ nosetests.xml
32
+
33
+ # Complexity
34
+ output/*.html
35
+ output/*/index.html
36
+
37
+ # Sphinx
38
+ docs/_build
39
+
40
+ # Cookiecutter
41
+ output/
42
+
43
+ .workon
44
+
45
+ **.wav
46
+ **.joblib
47
+
48
+ **/__pycache__
49
+
50
+ #Excel files
51
+ *.xlsx
52
+ #csv files
53
+ *.csv
54
+ #virtual environments
55
+ **/.venv
56
+ **/env
57
+ **/.env
58
+ *.DS_Store
59
+ *.pdf
60
+ **/node_modules
61
+ **/dist
62
+ *.log
63
+ .DS_Store
64
+ **/package-lock.json
65
+ # Standalone npm example (outside the pnpm workspace): its lockfile pins the tested dependency set.
66
+ !typescript/examples/tanstack-ai/package-lock.json
67
+ **/tsconfig.tsbuildinfo
68
+ **/.fi
69
+ **/.pytest_cache
70
+ planning/
71
+
72
+ # Java build artifacts
73
+ **/target/
74
+ **/.settings/
75
+ **/.project
76
+ **/.classpath
77
+ **/.factorypath
78
+ *.class
79
+ *.jar
80
+ *.war
81
+
82
+ # C# build artifacts
83
+ **/bin/
84
+ **/obj/
85
+
86
+ # Python
87
+ **/uv.lock
@@ -0,0 +1,201 @@
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, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may accept and charge a
167
+ fee for acceptance of support, warranty, indemnity, or other liability
168
+ obligations and/or rights consistent with this License. However, in
169
+ accepting such obligations, You may act only on Your own behalf and on
170
+ Your sole responsibility, not on behalf of any other Contributor, and
171
+ only if You agree to indemnify, defend, and hold each Contributor
172
+ harmless for any liability incurred by, or claims asserted against,
173
+ such Contributor by reason of your accepting any such warranty or
174
+ additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2024-2026 Future AGI, Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,94 @@
1
+ Metadata-Version: 2.5
2
+ Name: traceAI-agentscope
3
+ Version: 0.1.0
4
+ Summary: Future AGI adapter for AgentScope native OpenTelemetry tracing
5
+ Project-URL: Repository, https://github.com/future-agi/traceAI
6
+ Project-URL: Documentation, https://docs.futureagi.com/docs/integrations/frameworks/agentscope
7
+ Author-email: Future AGI <no-reply@futureagi.com>
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Requires-Python: <3.14,>=3.11
11
+ Requires-Dist: agentscope<2.1,>=2.0.10
12
+ Requires-Dist: fi-instrumentation-otel<2,>=1.2.2
13
+ Requires-Dist: opentelemetry-sdk<2,>=1.39
14
+ Provides-Extra: dev
15
+ Requires-Dist: build<2,>=1.2; extra == 'dev'
16
+ Requires-Dist: hatchling<2,>=1.27; extra == 'dev'
17
+ Requires-Dist: mypy<2,>=1.15; extra == 'dev'
18
+ Requires-Dist: pytest<9,>=8; extra == 'dev'
19
+ Description-Content-Type: text/markdown
20
+
21
+ # traceAI-agentscope
22
+
23
+ Send AgentScope's native reply, model-call and tool-execution spans to Future AGI. This adapter uses AgentScope's `TracingMiddleware`; it does not wrap model SDKs or create a second set of spans.
24
+
25
+ Requires Python 3.11–3.13 and AgentScope 2.0.10–2.0.x.
26
+
27
+ ```bash
28
+ pip install traceAI-agentscope
29
+ export FI_API_KEY="YOUR_FI_API_KEY"
30
+ export FI_SECRET_KEY="YOUR_FI_SECRET_KEY"
31
+ export OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
32
+ ```
33
+
34
+ ```python
35
+ import asyncio
36
+ import os
37
+
38
+ from agentscope.agent import Agent
39
+ from agentscope.credential import OpenAICredential
40
+ from agentscope.message import UserMsg
41
+ from agentscope.model import OpenAIChatModel
42
+ from agentscope.state import AgentState
43
+ from traceai_agentscope import configure, TracingMiddleware
44
+
45
+
46
+ async def main():
47
+ tracing = configure(project_name="support-agent")
48
+ try:
49
+ agent = Agent(
50
+ name="support",
51
+ system_prompt="Explain technical concepts in one short paragraph.",
52
+ model=OpenAIChatModel(
53
+ credential=OpenAICredential(api_key=os.environ["OPENAI_API_KEY"]),
54
+ model="gpt-4o-mini",
55
+ ),
56
+ state=AgentState(session_id="support-session-001"),
57
+ middlewares=[TracingMiddleware()],
58
+ )
59
+ answer = await agent.reply(UserMsg(name="user", content="What is a trace?"))
60
+ print(answer)
61
+ finally:
62
+ # Lifecycle methods are synchronous; keep blocking work off your async loop.
63
+ await asyncio.to_thread(tracing.shutdown, 5000)
64
+
65
+
66
+ asyncio.run(main())
67
+ ```
68
+
69
+ Open **Observe** and select `support-agent`. Replies are `AGENT` spans, model calls are `LLM` spans, and tool executions are `TOOL` spans. Native trace IDs, parentage and timing are preserved. Model token counts stay on model spans. The native conversation ID is also exported as `session.id`; use an opaque session identifier, not an email address or prompt.
70
+
71
+ Use the adapter middleware **instead of**, not alongside, the native `TracingMiddleware`. Configuration alone does not correct the native middleware's returned-tool-error status. Do not also instrument the model SDK for the same calls. Returned tool results with `state=ERROR` (`ToolResultBlock`, `ToolChunk`, or `ToolResponse`) are marked as errors at this destination, including intermediate streamed results. Exception messages and stacks remain excluded. Native synthetic spans for receipts of externally executed tools are not exported: they do not measure execution of those tools.
72
+
73
+ ## Content controls
74
+
75
+ Metadata-only is the default. Recognized operational identifiers and numeric settings are retained; arbitrary attributes, resource fields, link attributes, scope attributes, status descriptions and event payloads are not forwarded. Span names are rebuilt from the operation and an allowlisted identifier. Names, model identifiers and session IDs are metadata, not automatically anonymized; keep sensitive data out of them.
76
+
77
+ Set `capture_content=True` in `configure` to include native messages and tool arguments/results, with `input.value` and `output.value` aliases. Known credential and stacktrace fields in structured content are redacted, including nested JSON strings. This is **not** a free-text secret detector: messages and tool output can contain personal data or credentials in prose. Enable content capture only for approved application data. Malformed, overly nested or oversized structured values (over 65,536 characters) are omitted. AgentScope 2.0.10 emits tool results as opaque object representations, which are also omitted; upgrade to 2.0.11 to capture structured tool output.
78
+
79
+ Filtering applies only to this adapter's destination, before its export queue. AgentScope records content in memory unconditionally. Other processors on the global provider still receive the original native spans and need their own privacy controls.
80
+
81
+ ## Provider and lifecycle
82
+
83
+ `configure` reuses the global OpenTelemetry SDK provider, or installs one when no provider is registered. An explicit `provider=` must be that global provider or be installed before any other provider. An incompatible or disabled provider is rejected rather than silently exporting nothing. Sampling and span limits belong to the provider; the adapter does not change them.
84
+
85
+ The returned handle exposes `provider` and `owns_provider` (whether the adapter created it). It owns only its export pipeline: shutdown never stops the provider or other destinations, including when the adapter created the provider. A global provider cannot be replaced, so the installed provider stays reusable.
86
+
87
+ - `force_flush(timeout_millis=5000)` drains ended spans without detaching.
88
+ - `shutdown(timeout_millis=5000)` detaches immediately, drains queued spans and closes the exporter. Call it after finishing your agent operations.
89
+ - Both return `False` on a deadline or cleanup failure; a successful flush means queue drainage, not confirmed delivery to Future AGI. Cleanup may finish in the background after a deadline.
90
+ - Repeated configuration with the same explicit options shares one pipeline. Different options require shutdown first. Do not change credentials through environment variables while a pipeline is active; shut it down and configure again.
91
+ - Spans already open when you configure, or still open when you shut down, are not exported. Reconfiguration does not adopt old spans. At most 65,536 open spans and 2,048 queued ended spans are retained; overload drops spans.
92
+ - Reconfiguration waits for previous cleanup to complete by rejecting attempts while it is still closing. Overlapping configuration calls fail fast. A provider shut down through OpenTelemetry cannot be reused.
93
+
94
+ `FI_BASE_URL` selects your Future AGI origin. Alternatively pass a full OTLP HTTP `endpoint` and `headers`, or a custom OpenTelemetry `exporter` (not both). The default exporter uses OTLP HTTP/protobuf with a 10-second request timeout. A custom exporter transfers to this pipeline and must implement `export`, `force_flush` and `shutdown`. Lifecycle deadlines bound callers' waits even for a stuck custom exporter; daemon cleanup cannot guarantee delivery on process termination.
@@ -0,0 +1,74 @@
1
+ # traceAI-agentscope
2
+
3
+ Send AgentScope's native reply, model-call and tool-execution spans to Future AGI. This adapter uses AgentScope's `TracingMiddleware`; it does not wrap model SDKs or create a second set of spans.
4
+
5
+ Requires Python 3.11–3.13 and AgentScope 2.0.10–2.0.x.
6
+
7
+ ```bash
8
+ pip install traceAI-agentscope
9
+ export FI_API_KEY="YOUR_FI_API_KEY"
10
+ export FI_SECRET_KEY="YOUR_FI_SECRET_KEY"
11
+ export OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
12
+ ```
13
+
14
+ ```python
15
+ import asyncio
16
+ import os
17
+
18
+ from agentscope.agent import Agent
19
+ from agentscope.credential import OpenAICredential
20
+ from agentscope.message import UserMsg
21
+ from agentscope.model import OpenAIChatModel
22
+ from agentscope.state import AgentState
23
+ from traceai_agentscope import configure, TracingMiddleware
24
+
25
+
26
+ async def main():
27
+ tracing = configure(project_name="support-agent")
28
+ try:
29
+ agent = Agent(
30
+ name="support",
31
+ system_prompt="Explain technical concepts in one short paragraph.",
32
+ model=OpenAIChatModel(
33
+ credential=OpenAICredential(api_key=os.environ["OPENAI_API_KEY"]),
34
+ model="gpt-4o-mini",
35
+ ),
36
+ state=AgentState(session_id="support-session-001"),
37
+ middlewares=[TracingMiddleware()],
38
+ )
39
+ answer = await agent.reply(UserMsg(name="user", content="What is a trace?"))
40
+ print(answer)
41
+ finally:
42
+ # Lifecycle methods are synchronous; keep blocking work off your async loop.
43
+ await asyncio.to_thread(tracing.shutdown, 5000)
44
+
45
+
46
+ asyncio.run(main())
47
+ ```
48
+
49
+ Open **Observe** and select `support-agent`. Replies are `AGENT` spans, model calls are `LLM` spans, and tool executions are `TOOL` spans. Native trace IDs, parentage and timing are preserved. Model token counts stay on model spans. The native conversation ID is also exported as `session.id`; use an opaque session identifier, not an email address or prompt.
50
+
51
+ Use the adapter middleware **instead of**, not alongside, the native `TracingMiddleware`. Configuration alone does not correct the native middleware's returned-tool-error status. Do not also instrument the model SDK for the same calls. Returned tool results with `state=ERROR` (`ToolResultBlock`, `ToolChunk`, or `ToolResponse`) are marked as errors at this destination, including intermediate streamed results. Exception messages and stacks remain excluded. Native synthetic spans for receipts of externally executed tools are not exported: they do not measure execution of those tools.
52
+
53
+ ## Content controls
54
+
55
+ Metadata-only is the default. Recognized operational identifiers and numeric settings are retained; arbitrary attributes, resource fields, link attributes, scope attributes, status descriptions and event payloads are not forwarded. Span names are rebuilt from the operation and an allowlisted identifier. Names, model identifiers and session IDs are metadata, not automatically anonymized; keep sensitive data out of them.
56
+
57
+ Set `capture_content=True` in `configure` to include native messages and tool arguments/results, with `input.value` and `output.value` aliases. Known credential and stacktrace fields in structured content are redacted, including nested JSON strings. This is **not** a free-text secret detector: messages and tool output can contain personal data or credentials in prose. Enable content capture only for approved application data. Malformed, overly nested or oversized structured values (over 65,536 characters) are omitted. AgentScope 2.0.10 emits tool results as opaque object representations, which are also omitted; upgrade to 2.0.11 to capture structured tool output.
58
+
59
+ Filtering applies only to this adapter's destination, before its export queue. AgentScope records content in memory unconditionally. Other processors on the global provider still receive the original native spans and need their own privacy controls.
60
+
61
+ ## Provider and lifecycle
62
+
63
+ `configure` reuses the global OpenTelemetry SDK provider, or installs one when no provider is registered. An explicit `provider=` must be that global provider or be installed before any other provider. An incompatible or disabled provider is rejected rather than silently exporting nothing. Sampling and span limits belong to the provider; the adapter does not change them.
64
+
65
+ The returned handle exposes `provider` and `owns_provider` (whether the adapter created it). It owns only its export pipeline: shutdown never stops the provider or other destinations, including when the adapter created the provider. A global provider cannot be replaced, so the installed provider stays reusable.
66
+
67
+ - `force_flush(timeout_millis=5000)` drains ended spans without detaching.
68
+ - `shutdown(timeout_millis=5000)` detaches immediately, drains queued spans and closes the exporter. Call it after finishing your agent operations.
69
+ - Both return `False` on a deadline or cleanup failure; a successful flush means queue drainage, not confirmed delivery to Future AGI. Cleanup may finish in the background after a deadline.
70
+ - Repeated configuration with the same explicit options shares one pipeline. Different options require shutdown first. Do not change credentials through environment variables while a pipeline is active; shut it down and configure again.
71
+ - Spans already open when you configure, or still open when you shut down, are not exported. Reconfiguration does not adopt old spans. At most 65,536 open spans and 2,048 queued ended spans are retained; overload drops spans.
72
+ - Reconfiguration waits for previous cleanup to complete by rejecting attempts while it is still closing. Overlapping configuration calls fail fast. A provider shut down through OpenTelemetry cannot be reused.
73
+
74
+ `FI_BASE_URL` selects your Future AGI origin. Alternatively pass a full OTLP HTTP `endpoint` and `headers`, or a custom OpenTelemetry `exporter` (not both). The default exporter uses OTLP HTTP/protobuf with a 10-second request timeout. A custom exporter transfers to this pipeline and must implement `export`, `force_flush` and `shutdown`. Lifecycle deadlines bound callers' waits even for a stuck custom exporter; daemon cleanup cannot guarantee delivery on process termination.
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27,<2"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "traceAI-agentscope"
7
+ version = "0.1.0"
8
+ description = "Future AGI adapter for AgentScope native OpenTelemetry tracing"
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ authors = [{name = "Future AGI", email = "no-reply@futureagi.com"}]
12
+ requires-python = ">=3.11,<3.14"
13
+ dependencies = [
14
+ "agentscope>=2.0.10,<2.1",
15
+ "fi-instrumentation-otel>=1.2.2,<2",
16
+ "opentelemetry-sdk>=1.39,<2",
17
+ ]
18
+
19
+ [project.optional-dependencies]
20
+ dev = ["pytest>=8,<9", "build>=1.2,<2", "hatchling>=1.27,<2", "mypy>=1.15,<2"]
21
+
22
+ [project.urls]
23
+ Repository = "https://github.com/future-agi/traceAI"
24
+ Documentation = "https://docs.futureagi.com/docs/integrations/frameworks/agentscope"
25
+
26
+ [tool.hatch.build.targets.wheel]
27
+ packages = ["traceai_agentscope"]
28
+
29
+ [tool.pytest.ini_options]
30
+ testpaths = ["tests"]
31
+
32
+ [tool.mypy]
33
+ ignore_missing_imports = true
34
+ follow_imports = "silent"
@@ -0,0 +1,44 @@
1
+ import pytest
2
+ from opentelemetry import trace
3
+ from opentelemetry.sdk.resources import Resource
4
+ from opentelemetry.sdk.trace import TracerProvider
5
+ from opentelemetry.sdk.trace.export import SimpleSpanProcessor
6
+ from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter
7
+ from opentelemetry.util._once import Once
8
+ from traceai_agentscope import _lifecycle
9
+
10
+
11
+ @pytest.fixture(autouse=True)
12
+ def isolated_global(monkeypatch):
13
+ # OTel global provider registration is once-only in production. Isolate tests.
14
+ monkeypatch.setattr(trace, "_TRACER_PROVIDER", None)
15
+ monkeypatch.setattr(trace, "_TRACER_PROVIDER_SET_ONCE", Once())
16
+ monkeypatch.setattr(_lifecycle, "_slots", _lifecycle.WeakKeyDictionary())
17
+ for name in (
18
+ "FI_API_KEY",
19
+ "FI_SECRET_KEY",
20
+ "OTEL_EXPORTER_OTLP_HEADERS",
21
+ "OTEL_EXPORTER_OTLP_TRACES_HEADERS",
22
+ "OTEL_SDK_DISABLED",
23
+ "OTEL_TRACES_SAMPLER",
24
+ "OTEL_TRACES_SAMPLER_ARG",
25
+ "OTEL_PYTHON_TRACER_PROVIDER",
26
+ ):
27
+ monkeypatch.delenv(name, raising=False)
28
+ monkeypatch.setenv("FI_BASE_URL", "http://127.0.0.1:9")
29
+ yield
30
+ provider = trace.get_tracer_provider()
31
+ if isinstance(provider, TracerProvider):
32
+ provider.shutdown()
33
+
34
+
35
+ @pytest.fixture
36
+ def shared():
37
+ provider = TracerProvider(
38
+ resource=Resource({"private.resource": "PRIVATE_RESOURCE"}),
39
+ shutdown_on_exit=False,
40
+ )
41
+ raw = InMemorySpanExporter()
42
+ provider.add_span_processor(SimpleSpanProcessor(raw))
43
+ trace.set_tracer_provider(provider)
44
+ return provider, raw