Skip to content

Commit 45ded8f

Browse files
authored
Merge pull request #416 from agentuniverse-ai/Release_20250615
feat: Release version 0.0.18
2 parents dffd7e0 + 1b960b8 commit 45ded8f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+4393
-599
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,27 @@ Note - Additional remarks regarding the version.
2424
***************************************************
2525

2626
# Version Update History
27+
## [0.0.18] - 2025-07-10
28+
### Added
29+
- Added observability capabilities for agent applications based on the OTel protocol
30+
Established observation standards for aU agent applications based on OTel (OpenTelemetry) protocol. Comprehensive metrics and traces (including token consumption, latency, success rate, etc.) are collected across key components such as agents, LLMs, and tools. The implementation supports integration with mainstream observability frameworks including SigNoz, Jaeger, and Prometheus, enabling full lifecycle observability for agents.
31+
32+
- Added async Sink and Sender components for SLS Logger
33+
34+
### Fixed
35+
- MCP service in Stdio mode now supports user-configurable environment parameter
36+
37+
### Note
38+
- Third-party package dependency changes (Format: old version -> new version; single version means new)
39+
- openai ("1.13.3" -> "1.55.3")
40+
- opentelemetry-api ("^1.25.0")
41+
- opentelemetry-sdk ("^1.25.0")
42+
- opentelemetry-semantic-conventions (">=0.48b0")
43+
- opentelemetry-exporter-otlp-proto-http ("^1.25.0")
44+
- httpx ("0.27.2" -> ">=0.27.2")
45+
- jsonlines ("^4.0.0")
46+
- Other code optimizations and documentation updates
47+
2748
## [0.0.17] - 2025-05-22
2849
### Added
2950
- MCP Integration & Publishing Capabilities

CHANGELOG_zh.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,27 @@ Note - 对于版本的额外说明。
2424
***************************************************
2525

2626
# 版本更新记录
27+
## [0.0.18] - 2025-07-10
28+
### Added
29+
- 新增基于OTel协议的智能体应用可观测能力
30+
制定aU智能体应用的观测标准,基于OTel(OpenTelemetry)协议,对智能体、模型、工具等关键组件的token消耗、耗时、成功率等核心指标以及调用链(trace)进行全面采集与观测,并适配 SigNoz、Jaeger、Prometheus 等主流观测框架,从而实现对智能体全生命周期的可观测性支持。
31+
32+
- 新增异步SLS日志Sink、Sender组件
33+
34+
### Fixed
35+
- MCP服务调用Stdio模式下env参数支持用户配置透传
36+
37+
### Note
38+
- 第三方包依赖变更(格式:原版本->新版本,只包含一个版本号为新引入)
39+
- openai ("1.13.3" -> "1.55.3")
40+
- opentelemetry-api ("^1.25.0")
41+
- opentelemetry-sdk ("^1.25.0")
42+
- opentelemetry-semantic-conventions (">=0.48b0")
43+
- opentelemetry-exporter-otlp-proto-http ("^1.25.0")
44+
- httpx ("0.27.2" -> ">=0.27.2")
45+
- jsonlines ("^4.0.0")
46+
- 其他代码优化与文档更新
47+
2748
## [0.0.17] - 2025-05-22
2849
### Added
2950
- 新增MCP接入与发布能力

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Language version: [English](./README.md) | [中文](./README_zh.md) | [日本語
55
![](https://img.shields.io/badge/framework-agentUniverse-pink)
66
![](https://img.shields.io/badge/python-3.10%2B-blue?logo=Python)
77
[![](https://img.shields.io/badge/%20license-Apache--2.0-yellow)](LICENSE)
8-
[![Static Badge](https://img.shields.io/badge/pypi-v0.0.17-blue?logo=pypi)](https://pypi.org/project/agentUniverse/)
8+
[![Static Badge](https://img.shields.io/badge/pypi-v0.0.18-blue?logo=pypi)](https://pypi.org/project/agentUniverse/)
99

1010
![](docs/guidebook/_picture/logo_bar.jpg)
1111
****************************************
@@ -89,6 +89,9 @@ You can learn how to create effective agent patterns into templates through the
8989
#### Using and Publishing MCP Servers
9090
You can learn how to quickly use or publish MCP servers in agentUniverse framework by referring to [How to Use MCP Servers](docs/guidebook/en/How-to/Use%20and%20Publish%20MCP%20Server/How_to_Use_MCP_Servers.md) and [How to Publish MCP Servers](docs/guidebook/en/How-to/Use%20and%20Publish%20MCP%20Server/How_to_Publish_MCP_Servers.md).
9191

92+
#### Agent Application Observability
93+
agentUniverse provides a standardized observability framework for agent applications. Based on the OpenTelemetry protocol, it enables comprehensive data collection and monitoring of critical components such as agents, LLMs, and tools, facilitating full lifecycle tracking of agents. You can learn how to utilize these observability capabilities in the [Agent Application Observability](docs/guidebook/en/In-Depth_Guides/Tech_Capabilities/Observability/Observability_with_OTEL.md) section.
94+
9295
#### Common Tips and Advanced Techniques
9396
You can learn more advanced techniques in the agent application building process through other documents in the [Get_Start](./docs/guidebook/en/Get_Start), such as how to add a memory module into the intelligent agent process and how to effectively manage prompts within the project.
9497
****************************************

README_zh.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
![](https://img.shields.io/badge/framework-agentUniverse-pink)
66
![](https://img.shields.io/badge/python-3.10%2B-blue?logo=Python)
77
[![](https://img.shields.io/badge/%20license-Apache--2.0-yellow)](LICENSE)
8-
[![Static Badge](https://img.shields.io/badge/pypi-v0.0.17-blue?logo=pypi)](https://pypi.org/project/agentUniverse/)
8+
[![Static Badge](https://img.shields.io/badge/pypi-v0.0.18-blue?logo=pypi)](https://pypi.org/project/agentUniverse/)
99

1010
![](docs/guidebook/_picture/logo_bar.jpg)
1111
****************************************
@@ -26,8 +26,8 @@
2626

2727
The LLM model integration can be accomplished with simple configuration, currently agentUniverse supported models include:
2828

29-
|-|供应商| 模型 |
30-
|:-----:|:--------:|:-----------------------------------------------------------------------------------------------------------------:|
29+
|-|供应商| 模型 |
30+
|:-----:|:--------:|:------------------------------------------------------------------------------------------------------------:|
3131
|<img src="https://github.com/user-attachments/assets/b7b0f2ce-3250-4008-b6d7-4712a983deb9" height="25">|Qwen| qwen3 Series(qwen3-235b-a22b、qwen3-32b、qwen3-30b-a3b, etc.) 、qwen2.5-72b-instruct、qwq-32b-preview、qwen-max、… |
3232
|<img src="https://github.com/user-attachments/assets/5a997feb-bef4-4e53-ac3e-d38221e5399c" height="25">|Deepseek| deepseek-r1、deepseek-v3、deepseek-r1-distill-qwen-32b、… |
3333
|<img src="https://github.com/user-attachments/assets/0b50e555-65e8-49b2-b725-f3f71ee7daed" height="25">|OpenAI| GPT-4o、GPT-4o mini、OpenAI o1、OpenAI o3-mini、… |
@@ -98,6 +98,9 @@ pip install agentUniverse
9898
#### 使用与发布MCP服务
9999
您可以通过 [如何使用MCP服务](./docs/guidebook/zh/How-to/使用与发布MCP服务/如何使用MCP服务.md)[如何发布MCP服务](./docs/guidebook/zh/How-to/使用与发布MCP服务/如何发布MCP服务.md) 章节掌握如何快速在智能体框架中使用或发布MCP服务。
100100

101+
#### 智能体应用观测
102+
agentUniverse拥有标准的智能体应用观测标准,并基于OpenTelemetry协议对于智能体、模型、工具等重要组件进行全方位采集与观测,方便用户追踪智能体全生命周期,您可以在 [智能体应用可观测](./docs/guidebook/zh/In-Depth_Guides/技术组件/可观测/基于OTEL的可观测能力.md) 章节掌握如何使用观测能力。
103+
101104
#### 常用使用技巧
102105
您可以通过 [开始章节](./docs/guidebook/zh/开始使用) 下的其他文档了解智能体应用构建过程中的其他进阶技巧,例如如何在智能体过程中加入记忆模块、如何有效的管理项目中的prompt等。
103106

agentuniverse/agent/action/knowledge/doc_processor/token_text_splitter.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ class TokenTextSplitter(DocProcessor):
2727
@property
2828
def splitter(self) -> Splitter:
2929
if not self.__splitter:
30-
self.__splitter = Splitter(separator=self.separator,
31-
chunk_size=self.chunk_size,
32-
chunk_overlap=self.chunk_overlap)
30+
self.__splitter = Splitter(
31+
encoding_name=self.encoding_name,
32+
model_name=self.model_name,
33+
chunk_size=self.chunk_size,
34+
chunk_overlap=self.chunk_overlap
35+
)
3336
return self.__splitter
3437

3538
def _process_docs(self, origin_docs: List[Document], query: Query = None) -> \

agentuniverse/agent/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
from agentuniverse.base.util.logging.logging_util import LOGGER
4747
from agentuniverse.base.util.memory_util import generate_messages, get_memory_string
4848
from agentuniverse.base.util.system_util import process_dict_with_funcs, is_system_builtin
49-
from agentuniverse.base.util.tracing.au_trace_manager import AuTraceManager
49+
from agentuniverse.base.tracing.au_trace_manager import AuTraceManager
5050
from agentuniverse.llm.llm import LLM
5151
from agentuniverse.llm.llm_manager import LLMManager
5252
from agentuniverse.prompt.chat_prompt import ChatPrompt

agentuniverse/agent_serve/web/gunicorn_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .post_fork_queue import POST_FORK_QUEUE
1414
from ...base.annotation.singleton import singleton
1515
from ...base.context.framework_context_manager import FrameworkContextManager
16-
from ...base.util.tracing.au_trace_manager import AuTraceManager
16+
from agentuniverse.base.tracing.au_trace_manager import AuTraceManager
1717

1818
DEFAULT_GUNICORN_CONFIG = {
1919
'bind': '127.0.0.1:8888',

agentuniverse/agent_serve/web/request_task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from .thread_with_result import ThreadWithReturnValue
2626
from agentuniverse.base.util.logging.logging_util import LOGGER
2727
from ...agent.output_object import OutputObject
28-
from agentuniverse.base.util.tracing.au_trace_manager import AuTraceManager
28+
from agentuniverse.base.tracing.au_trace_manager import AuTraceManager
2929
from agentuniverse.base.util.logging.general_logger import get_context_prefix
3030
from agentuniverse.base.util.logging.log_type_enum import LogTypeEnum
3131

agentuniverse/agent_serve/web/thread_with_result.py

Lines changed: 61 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
# @Email : fanen.lhy@antgroup.com
77
# @FileName: thread_with_result.py
88

9-
import weakref
10-
from concurrent.futures.thread import ThreadPoolExecutor, _worker, \
11-
_threads_queues
9+
from concurrent.futures import ThreadPoolExecutor, Future
1210
from threading import Thread
11+
from typing import Callable
12+
13+
from opentelemetry import context as otel_context
1314

1415
from agentuniverse.base.context.context_coordinator import ContextCoordinator
1516

@@ -34,11 +35,14 @@ def run(self):
3435
"""Run the target func and save result in _return."""
3536
if self.target is not None:
3637
# set the context values in the thread
37-
ContextCoordinator.recover_context(self._context_pack)
38+
otel_token = ContextCoordinator.recover_context(self._context_pack)
3839
try:
3940
self._return = self.target(*self.args, **self.kwargs)
4041
except Exception as e:
4142
self.error = e
43+
finally:
44+
if otel_token:
45+
otel_context.detach(otel_token)
4246

4347
def result(self):
4448
"""Wait for target func finished, then return the result or raise an
@@ -49,27 +53,58 @@ def result(self):
4953
return self._return
5054

5155

56+
class ContextAwareFuture(Future):
57+
"""A Future that can store context and error information."""
58+
59+
def __init__(self):
60+
super().__init__()
61+
self.error = None
62+
self._context_pack = None
63+
64+
5265
class ThreadPoolExecutorWithReturnValue(ThreadPoolExecutor):
66+
"""A ThreadPoolExecutor that preserves context across threads."""
67+
68+
def submit(self, fn: Callable, *args, **kwargs) -> ContextAwareFuture:
69+
"""Submit a callable to be executed with context preservation."""
70+
context_pack = ContextCoordinator.save_context()
71+
future = ContextAwareFuture()
72+
future._context_pack = context_pack
73+
74+
def context_wrapper():
75+
otel_token = None
76+
try:
77+
otel_token = ContextCoordinator.recover_context(context_pack)
78+
79+
result = fn(*args, **kwargs)
80+
future.set_result(result)
81+
82+
except Exception as e:
83+
future.error = e
84+
future.set_exception(e)
85+
86+
finally:
87+
if otel_token:
88+
otel_context.detach(otel_token)
89+
90+
super().submit(context_wrapper)
91+
92+
return future
93+
94+
def map(self, func: Callable, *iterables, timeout=None, chunksize=1):
95+
"""Apply func to each element of iterables with context preservation."""
96+
context_pack = ContextCoordinator.save_context()
97+
98+
def context_aware_func(*args):
99+
otel_token = None
100+
try:
101+
otel_token = ContextCoordinator.recover_context(context_pack)
102+
return func(*args)
103+
except Exception as e:
104+
raise e
105+
finally:
106+
if otel_token:
107+
otel_context.detach(otel_token)
53108

54-
def _adjust_thread_count(self):
55-
# if idle threads are available, don't spin new threads
56-
if self._idle_semaphore.acquire(timeout=0):
57-
return
58-
59-
# When the executor gets lost, the weakref callback will wake up
60-
# the worker threads.
61-
def weakref_cb(_, q=self._work_queue):
62-
q.put(None)
63-
64-
num_threads = len(self._threads)
65-
if num_threads < self._max_workers:
66-
thread_name = '%s_%d' % (self._thread_name_prefix or self,
67-
num_threads)
68-
t = ThreadWithReturnValue(name=thread_name, target=_worker,
69-
args=(weakref.ref(self, weakref_cb),
70-
self._work_queue,
71-
self._initializer,
72-
self._initargs))
73-
t.start()
74-
self._threads.add(t)
75-
_threads_queues[t] = self._work_queue
109+
return super().map(context_aware_func, *iterables,
110+
timeout=timeout, chunksize=chunksize)

agentuniverse/base/agentuniverse.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from agentuniverse.agent_serve.web.web_booster import ACTIVATE_OPTIONS
3434
from agentuniverse.agent_serve.web.post_fork_queue import POST_FORK_QUEUE
3535
from agentuniverse.agent_serve.web.web_util import FlaskServerManager
36-
36+
from agentuniverse.base.tracing.otel.telemetry_manager import TelemetryManager
3737

3838
@singleton
3939
class AgentUniverse(object):
@@ -93,6 +93,9 @@ def start(self, config_path: str = None, core_mode: bool = False):
9393
config_path)
9494
init_loggers(log_config_path)
9595

96+
# Init OTEL configs
97+
TelemetryManager().init_from_config(configer.value.get('OTEL', {}))
98+
9699
# init web request task database
97100
RequestLibrary(configer=configer)
98101

0 commit comments

Comments
 (0)