Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions py/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ def test_strands(session, version):
@nox.session()
@nox.parametrize("version", AGENTSCOPE_VERSIONS, ids=AGENTSCOPE_VERSIONS)
def test_agentscope(session, version):
if version == LATEST and sys.version_info < (3, 11):
session.skip("AgentScope 2.x requires Python 3.11+")
_install_test_deps(session)
_install_matrix_dep(session, "agentscope", version)
_install_group_locked(session, "test-agentscope")
Expand Down
2 changes: 1 addition & 1 deletion py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ latest = "agno==2.6.9"
"2.1.0" = "agno==2.1.0"

[tool.braintrust.matrix.agentscope]
latest = "agentscope==1.0.21"
latest = "agentscope==2.0.0"
"1.0.0" = "agentscope==1.0.0"

[tool.braintrust.matrix.autogen-agentchat]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
interactions:
- request:
body: '{"messages":[{"role":"system","name":"system","content":[{"type":"text","text":"You
are a helpful assistant. Be brief."}]},{"role":"user","name":"user","content":[{"type":"text","text":"Say
hi in two words."}]}],"model":"gpt-4o-mini","stream":true,"stream_options":{"include_usage":true},"temperature":0}'
are a concise assistant. Answer in one sentence."}]},{"role":"user","name":"user","content":[{"type":"text","text":"Say
hello in exactly two words."}]}],"model":"gpt-4o-mini","stream":false,"temperature":0}'
headers:
Accept:
- application/json
Expand All @@ -11,7 +11,7 @@ interactions:
Connection:
- keep-alive
Content-Length:
- '304'
- '290'
Content-Type:
- application/json
Host:
Expand Down Expand Up @@ -40,40 +40,136 @@ interactions:
uri: https://api.openai.com/v1/chat/completions
response:
body:
string: 'data: {"id":"chatcmpl-DX7NZBTmBc9FvHicZnqomTwNlJ2xI","object":"chat.completion.chunk","created":1776785561,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_a7190374f3","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"MSWgZo9n2"}


data: {"id":"chatcmpl-DX7NZBTmBc9FvHicZnqomTwNlJ2xI","object":"chat.completion.chunk","created":1776785561,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_a7190374f3","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"EYLOkE"}


data: {"id":"chatcmpl-DX7NZBTmBc9FvHicZnqomTwNlJ2xI","object":"chat.completion.chunk","created":1776785561,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_a7190374f3","choices":[{"index":0,"delta":{"content":"
there"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"OsMQm"}


data: {"id":"chatcmpl-DX7NZBTmBc9FvHicZnqomTwNlJ2xI","object":"chat.completion.chunk","created":1776785561,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_a7190374f3","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"LJrnGeP6qP"}


data: {"id":"chatcmpl-DX7NZBTmBc9FvHicZnqomTwNlJ2xI","object":"chat.completion.chunk","created":1776785561,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_a7190374f3","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null,"obfuscation":"0QFrc"}


data: {"id":"chatcmpl-DX7NZBTmBc9FvHicZnqomTwNlJ2xI","object":"chat.completion.chunk","created":1776785561,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_a7190374f3","choices":[],"usage":{"prompt_tokens":29,"completion_tokens":3,"total_tokens":32,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}},"obfuscation":"3tj5TjOjSkh"}


data: [DONE]


'
string: "{\n \"id\": \"chatcmpl-DX7NRqUSH6XKNRubUSWlhKnNmPNDB\",\n \"object\":
\"chat.completion\",\n \"created\": 1776785553,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
\"assistant\",\n \"content\": \"Hello there!\",\n \"refusal\":
null,\n \"annotations\": []\n },\n \"logprobs\": null,\n
\ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\":
32,\n \"completion_tokens\": 3,\n \"total_tokens\": 35,\n \"prompt_tokens_details\":
{\n \"cached_tokens\": 0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\":
{\n \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\":
\"default\",\n \"system_fingerprint\": \"fp_6042092f77\"\n}\n"
headers:
CF-Cache-Status:
- DYNAMIC
CF-Ray:
- 9efd715d39a53a03-YYZ
- 9efd712b8cb878a5-YYZ
Connection:
- keep-alive
Content-Type:
- text/event-stream; charset=utf-8
- application/json
Date:
- Tue, 21 Apr 2026 15:32:33 GMT
Server:
- cloudflare
Strict-Transport-Security:
- max-age=31536000; includeSubDomains; preload
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
access-control-expose-headers:
- X-Request-ID
alt-svc:
- h3=":443"; ma=86400
content-length:
- '818'
openai-organization:
- braintrust-data
openai-processing-ms:
- '303'
openai-project:
- proj_vsCSXafhhByzWOThMrJcZiw9
openai-version:
- '2020-10-01'
set-cookie:
- __cf_bm=vWZsqZxXqzK8jjN5seiu2E8BqryLRFNDYMLsGe_TiUQ-1776785553.2100453-1.0.1.1-jpJ.lEurU5WQQfPpsQ0nN6um.4nJttOu7.z79GA17wHU4ttEm4thC0lQws5XBcsmd95Y8H1r04sdMK4BboF_gKPQUBii3cJy1DzHoD4mGyzEG6boSWTr4toKmbv1ynts;
HttpOnly; Secure; Path=/; Domain=api.openai.com; Expires=Tue, 21 Apr 2026
16:02:33 GMT
x-openai-proxy-wasm:
- v0.1
x-ratelimit-limit-requests:
- '30000'
x-ratelimit-limit-tokens:
- '150000000'
x-ratelimit-remaining-requests:
- '29999'
x-ratelimit-remaining-tokens:
- '149999975'
x-ratelimit-reset-requests:
- 2ms
x-ratelimit-reset-tokens:
- 0s
x-request-id:
- req_249eb93d6eb44d4788eac0bc583d79de
status:
code: 200
message: OK
- request:
body: '{"messages":[{"role":"system","name":"system","content":[{"type":"text","text":"You
are a concise assistant. Answer in one sentence."}]},{"role":"user","name":"user","content":[{"type":"text","text":"Say
hello in exactly two words."}]}],"model":"gpt-4o-mini","stream":false,"temperature":0}'
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '290'
Content-Type:
- application/json
Host:
- api.openai.com
User-Agent:
- AsyncOpenAI/Python 2.31.0
X-Stainless-Arch:
- arm64
X-Stainless-Async:
- async:asyncio
X-Stainless-Lang:
- python
X-Stainless-OS:
- MacOS
X-Stainless-Package-Version:
- 2.31.0
X-Stainless-Runtime:
- CPython
X-Stainless-Runtime-Version:
- 3.14.3
x-stainless-read-timeout:
- '600'
x-stainless-retry-count:
- '0'
method: POST
uri: https://api.openai.com/v1/chat/completions
response:
body:
string: "{\n \"id\": \"chatcmpl-DX7O3zfeUJOH15DVkUmgReCpkVZxE\",\n \"object\":
\"chat.completion\",\n \"created\": 1776785591,\n \"model\": \"gpt-4o-mini-2024-07-18\",\n
\ \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\":
\"assistant\",\n \"content\": \"Hello there.\",\n \"refusal\":
null,\n \"annotations\": []\n },\n \"logprobs\": null,\n
\ \"finish_reason\": \"stop\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\":
32,\n \"completion_tokens\": 3,\n \"total_tokens\": 35,\n \"prompt_tokens_details\":
{\n \"cached_tokens\": 0,\n \"audio_tokens\": 0\n },\n \"completion_tokens_details\":
{\n \"reasoning_tokens\": 0,\n \"audio_tokens\": 0,\n \"accepted_prediction_tokens\":
0,\n \"rejected_prediction_tokens\": 0\n }\n },\n \"service_tier\":
\"default\",\n \"system_fingerprint\": \"fp_6042092f77\"\n}\n"
headers:
CF-Cache-Status:
- DYNAMIC
CF-Ray:
- 9efd721b1877964a-YYZ
Connection:
- keep-alive
Content-Type:
- application/json
Date:
- Tue, 21 Apr 2026 15:32:41 GMT
- Tue, 21 Apr 2026 15:33:11 GMT
Server:
- cloudflare
Strict-Transport-Security:
Expand All @@ -86,18 +182,20 @@ interactions:
- X-Request-ID
alt-svc:
- h3=":443"; ma=86400
content-length:
- '818'
openai-organization:
- braintrust-data
openai-processing-ms:
- '154'
- '364'
openai-project:
- proj_vsCSXafhhByzWOThMrJcZiw9
openai-version:
- '2020-10-01'
set-cookie:
- __cf_bm=PZv8LQidJAxjTDU4p9DA3ZPYHiXPGPyY_yhofay0BKY-1776785561.160069-1.0.1.1-GtP3HMxTLMRVoqZ.qRVYzRiP9D5xXLeNSfYc2L1uh17sfJU_JDi2C9GtNL8_WuOaaAuEjRvjpPzcLBZcbrY7zDtljrRC0NkG.74n4YLisUDTBu06g9VJdZ6OyV4Pm.kl;
- __cf_bm=0gBwjzu6S8NGJOZz8DHRfVPsaoNL7ANqedT8QLla.yg-1776785591.536904-1.0.1.1-8DZ8d3JNr0lAQVcDW_i1puCgA6zGjTDBjyq.9ZvoVuNK_ag_QIUapir9HQ0pbs6dOeD.7gMY9LWxtPR_K3mVM4jsFdH5p9pye0F0AXwbEYueTCwD4n9ncXY9D2TH4daa;
HttpOnly; Secure; Path=/; Domain=api.openai.com; Expires=Tue, 21 Apr 2026
16:02:41 GMT
16:03:11 GMT
x-openai-proxy-wasm:
- v0.1
x-ratelimit-limit-requests:
Expand All @@ -107,13 +205,13 @@ interactions:
x-ratelimit-remaining-requests:
- '29999'
x-ratelimit-remaining-tokens:
- '149999980'
- '149999975'
x-ratelimit-reset-requests:
- 2ms
x-ratelimit-reset-tokens:
- 0s
x-request-id:
- req_647b1639b38341d79da968edc2bff915
- req_1e92a22c0c334c628bcaf2941ab2d3ba
status:
code: 200
message: OK
Expand Down
4 changes: 4 additions & 0 deletions py/src/braintrust/integrations/agentscope/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

from .patchers import (
AgentCallPatcher,
AgentReplyPatcher,
ChatModelPatcher,
FanoutPipelinePatcher,
SequentialPipelinePatcher,
ToolkitCallToolFunctionPatcher,
ToolkitCallToolPatcher,
)


Expand All @@ -19,8 +21,10 @@ class AgentScopeIntegration(BaseIntegration):
min_version = "1.0.0"
patchers = (
AgentCallPatcher,
AgentReplyPatcher,
SequentialPipelinePatcher,
FanoutPipelinePatcher,
ToolkitCallToolFunctionPatcher,
ToolkitCallToolPatcher,
ChatModelPatcher,
)
22 changes: 20 additions & 2 deletions py/src/braintrust/integrations/agentscope/patchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,23 @@


class AgentCallPatcher(FunctionWrapperPatcher):
"""Patch AgentScope agent execution."""
"""Patch AgentScope 1.x agent execution."""

name = "agentscope.agent.call"
target_module = "agentscope.agent"
target_path = "AgentBase.__call__"
wrapper = _agent_call_wrapper


class AgentReplyPatcher(FunctionWrapperPatcher):
"""Patch AgentScope 2.x agent execution."""

name = "agentscope.agent.reply"
target_module = "agentscope.agent"
target_path = "Agent.reply"
wrapper = _agent_call_wrapper


class SequentialPipelinePatcher(FunctionWrapperPatcher):
"""Patch AgentScope sequential pipeline execution."""

Expand All @@ -39,14 +48,23 @@ class FanoutPipelinePatcher(FunctionWrapperPatcher):


class ToolkitCallToolFunctionPatcher(FunctionWrapperPatcher):
"""Patch AgentScope toolkit execution."""
"""Patch AgentScope 1.x toolkit execution."""

name = "agentscope.tool.call_tool_function"
target_module = "agentscope.tool"
target_path = "Toolkit.call_tool_function"
wrapper = _toolkit_call_tool_function_wrapper


class ToolkitCallToolPatcher(FunctionWrapperPatcher):
"""Patch AgentScope 2.x toolkit execution."""

name = "agentscope.tool.call_tool"
target_module = "agentscope.tool"
target_path = "Toolkit.call_tool"
wrapper = _toolkit_call_tool_function_wrapper


class _OpenAIChatModelPatcher(FunctionWrapperPatcher):
name = "agentscope.model.openai"
target_module = "agentscope.model"
Expand Down
Loading
Loading