Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions agentrun/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
- Integration: 框架集成 / Framework integration
"""

import os
from typing import TYPE_CHECKING

__version__ = "0.0.16"


# Agent Runtime
from agentrun.agent_runtime import (
AgentRuntime,
Expand Down Expand Up @@ -114,6 +116,7 @@
ResourceAlreadyExistError,
ResourceNotExistError,
)
from agentrun.utils.log import logger
from agentrun.utils.model import Status

# Server - 延迟导入以避免可选依赖问题
Expand Down Expand Up @@ -360,3 +363,23 @@ def __getattr__(name: str):
raise

raise AttributeError(f"module '{__name__}' has no attribute '{name}'")


if not os.getenv("DISABLE_BREAKING_CHANGES_WARNING"):
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DISABLE_BREAKING_CHANGES_WARNING is treated as “disabled if the variable exists with any value”. That means values like "0"/"false" will still disable the warning, which is inconsistent with how other env flags are parsed in this repo (e.g., AGENTRUN_SDK_DEBUG in agentrun/utils/log.py). Consider normalizing the value and only disabling when it’s truthy ("1", "true", "yes"), or reusing the same allow/deny list pattern used in log.py.

Suggested change
if not os.getenv("DISABLE_BREAKING_CHANGES_WARNING"):
_disable_warning_val = os.getenv("DISABLE_BREAKING_CHANGES_WARNING")
_disable_warning = (
_disable_warning_val is not None
and _disable_warning_val.strip().lower() in ("1", "true", "yes")
)
if not _disable_warning:

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning currently runs for all versions, but the message/PR description says it should display for “early versions”. To avoid accidentally warning on future stable releases, gate this by version (e.g., only when major version == 0, or when __version__ < 1.0.0), and keep the env var override as an escape hatch.

Suggested change
if not os.getenv("DISABLE_BREAKING_CHANGES_WARNING"):
def _is_early_version(version: str) -> bool:
"""Return True if the given version string represents an early (pre-1.0.0) version."""
parts = version.split(".")
if not parts:
# Conservatively treat unknown/malformed versions as early
return True
try:
major = int(parts[0])
except ValueError:
# Conservatively treat non-numeric major versions as early
return True
return major == 0
if _is_early_version(__version__) and not os.getenv(
"DISABLE_BREAKING_CHANGES_WARNING"
):

Copilot uses AI. Check for mistakes.
logger.warning(
f"当前您正在使用 AgentRun Python SDK 版本 {__version__}。"
"早期版本通常包含许多新功能,这些功能\033[1;33m 可能引入不兼容的变更"
" \033[0m。为避免潜在问题,我们强烈建议\033[1;32m 将依赖锁定为此版本"
" \033[0m。\nYou are currently using AgentRun Python SDK version"
f" {__version__}. Early versions often include many new features,"
" which\033[1;33m may introduce breaking changes\033[0m. To avoid"
" potential issues, we strongly recommend \033[1;32mpinning the"
" dependency to this version\033[0m.\n\033[2;3m pip install"
Comment on lines +371 to +377
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning text embeds raw ANSI escape sequences (e.g., \033[...m) inside the log message. If users redirect logs to files/CI systems or replace the SDK’s formatter/handlers, these control codes can end up as unreadable output. Prefer keeping the message plain and letting the logger formatter handle coloring (or only add ANSI codes when output is a TTY).

Copilot uses AI. Check for mistakes.
f" 'agentrun-sdk=={__version__}' \033[0m\n\n增加\033[2;3m"
" DISABLE_BREAKING_CHANGES_WARNING=1"
" \033[0m到您的环境变量以关闭此警告。\nAdd\033[2;3m"
" DISABLE_BREAKING_CHANGES_WARNING=1 \033[0mto your environment"
" variables to disable this warning.\n\nReleases:\033[2;3m"
" https://github.com/Serverless-Devs/agentrun-sdk-python/releases"
" \033[0m"
)
Loading