Skip to content

Commit 27dc963

Browse files
committed
feat: Add agentscope integration
1 parent 8b15ad6 commit 27dc963

16 files changed

+2184
-2
lines changed

py/noxfile.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def _pinned_python_version():
6262
# validate things work with or without them.
6363
VENDOR_PACKAGES = (
6464
"agno",
65+
"agentscope",
6566
"anthropic",
6667
"dspy",
6768
"openai",
@@ -89,6 +90,7 @@ def _pinned_python_version():
8990
# Keep LATEST for newest API coverage, and pin 2.4.0 to cover the 2.4 -> 2.5 breaking change
9091
# to internals we leverage for instrumentation.
9192
AGNO_VERSIONS = (LATEST, "2.4.0", "2.1.0")
93+
AGENTSCOPE_VERSIONS = (LATEST, "1.0.0")
9294
# pydantic_ai 1.x requires Python >= 3.10
9395
# Two test suites with different version requirements:
9496
# 1. wrap_openai approach: works with older versions (0.1.9+)
@@ -172,6 +174,16 @@ def test_agno(session, version):
172174
_run_core_tests(session)
173175

174176

177+
@nox.session()
178+
@nox.parametrize("version", AGENTSCOPE_VERSIONS, ids=AGENTSCOPE_VERSIONS)
179+
def test_agentscope(session, version):
180+
_install_test_deps(session)
181+
_install(session, "agentscope", version)
182+
_install(session, "openai")
183+
_run_tests(session, f"{INTEGRATION_DIR}/agentscope/test_agentscope.py")
184+
_run_core_tests(session)
185+
186+
175187
@nox.session()
176188
@nox.parametrize("version", ANTHROPIC_VERSIONS, ids=ANTHROPIC_VERSIONS)
177189
def test_anthropic(session, version):

py/src/braintrust/auto.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
import logging
88
from contextlib import contextmanager
99

10-
from braintrust.integrations import ADKIntegration, AgnoIntegration, AnthropicIntegration, ClaudeAgentSDKIntegration
10+
from braintrust.integrations import (
11+
ADKIntegration,
12+
AgentScopeIntegration,
13+
AgnoIntegration,
14+
AnthropicIntegration,
15+
ClaudeAgentSDKIntegration,
16+
)
1117

1218

1319
__all__ = ["auto_instrument"]
@@ -34,6 +40,7 @@ def auto_instrument(
3440
pydantic_ai: bool = True,
3541
google_genai: bool = True,
3642
agno: bool = True,
43+
agentscope: bool = True,
3744
claude_agent_sdk: bool = True,
3845
dspy: bool = True,
3946
adk: bool = True,
@@ -54,6 +61,7 @@ def auto_instrument(
5461
pydantic_ai: Enable Pydantic AI instrumentation (default: True)
5562
google_genai: Enable Google GenAI instrumentation (default: True)
5663
agno: Enable Agno instrumentation (default: True)
64+
agentscope: Enable AgentScope instrumentation (default: True)
5765
claude_agent_sdk: Enable Claude Agent SDK instrumentation (default: True)
5866
dspy: Enable DSPy instrumentation (default: True)
5967
adk: Enable Google ADK instrumentation (default: True)
@@ -116,6 +124,8 @@ def auto_instrument(
116124
results["google_genai"] = _instrument_google_genai()
117125
if agno:
118126
results["agno"] = _instrument_integration(AgnoIntegration)
127+
if agentscope:
128+
results["agentscope"] = _instrument_integration(AgentScopeIntegration)
119129
if claude_agent_sdk:
120130
results["claude_agent_sdk"] = _instrument_integration(ClaudeAgentSDKIntegration)
121131
if dspy:

py/src/braintrust/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ def get_vcr_config():
191191
"decode_compressed_response": True,
192192
"filter_headers": [
193193
"authorization",
194+
"Authorization",
194195
"openai-organization",
195196
"x-api-key",
196197
"api-key",
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
from .adk import ADKIntegration
2+
from .agentscope import AgentScopeIntegration
23
from .agno import AgnoIntegration
34
from .anthropic import AnthropicIntegration
45
from .claude_agent_sdk import ClaudeAgentSDKIntegration
56

67

7-
__all__ = ["ADKIntegration", "AgnoIntegration", "AnthropicIntegration", "ClaudeAgentSDKIntegration"]
8+
__all__ = [
9+
"ADKIntegration",
10+
"AgentScopeIntegration",
11+
"AgnoIntegration",
12+
"AnthropicIntegration",
13+
"ClaudeAgentSDKIntegration",
14+
]

py/src/braintrust/integrations/adk/test_adk.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def before_record_request(request):
4141
"cassette_library_dir": str(Path(__file__).parent / "cassettes"),
4242
"filter_headers": [
4343
"authorization",
44+
"Authorization",
4445
"x-goog-api-key",
4546
],
4647
"before_record_request": before_record_request,
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Braintrust integration for AgentScope."""
2+
3+
from braintrust.logger import NOOP_SPAN, current_span, init_logger
4+
5+
from .integration import AgentScopeIntegration
6+
7+
8+
__all__ = ["AgentScopeIntegration", "setup_agentscope"]
9+
10+
11+
def setup_agentscope(
12+
api_key: str | None = None,
13+
project_id: str | None = None,
14+
project_name: str | None = None,
15+
) -> bool:
16+
"""Setup Braintrust integration with AgentScope."""
17+
if current_span() == NOOP_SPAN:
18+
init_logger(project=project_name, api_key=api_key, project_id=project_id)
19+
20+
return AgentScopeIntegration.setup()

0 commit comments

Comments
 (0)