> ## Documentation Index
> Fetch the complete documentation index at: https://braintrust.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# AgentScope

If you are a coding agent, prefer the Braintrust [`bt` CLI](/reference/cli/quickstart) for repeatable, scriptable work: running evals, instrumenting code, querying logs, syncing data, managing functions, and configuring coding agents. Use the MCP server for reasoning over Braintrust data in conversation, such as ad-hoc lookups and exploration from your IDE.

[AgentScope](https://github.com/modelscope/agentscope) is a framework for building multi-agent systems. Braintrust traces AgentScope agents, pipelines, tool calls, and model requests so you can follow complete agent workflows in one trace.

<Note>
  This guide covers manual instrumentation. For quicker setup, use [auto-instrumentation](/instrument/trace-llm-calls).
</Note>

## Setup

Install Braintrust and AgentScope:

<CodeGroup>
  ```bash Python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
  pip install braintrust agentscope
  ```
</CodeGroup>

Set your API keys before you run your app:

```bash title=".env" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
BRAINTRUST_API_KEY=<your-braintrust-api-key>
OPENAI_API_KEY=<your-openai-api-key>
```

## Trace with AgentScope

Use `setup_agentscope()` when you want to trace AgentScope explicitly.

```python title="trace-agentscope.py" theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import asyncio

from braintrust.integrations.agentscope import setup_agentscope

setup_agentscope(project_name="agentscope-example")

from agentscope.agent import ReActAgent
from agentscope.formatter import OpenAIChatFormatter
from agentscope.memory import InMemoryMemory
from agentscope.message import Msg
from agentscope.model import OpenAIChatModel
from agentscope.tool import Toolkit


async def main():
    agent = ReActAgent(
        name="Friday",
        sys_prompt="You are a concise assistant. Answer in one sentence.",
        model=OpenAIChatModel(model_name="gpt-5-mini"),
        formatter=OpenAIChatFormatter(),
        toolkit=Toolkit(),
        memory=InMemoryMemory(),
    )
    if hasattr(agent, "set_console_output_enabled"):
        agent.set_console_output_enabled(False)
    elif hasattr(agent, "disable_console_output"):
        agent.disable_console_output()

    response = await agent(
        Msg(name="user", content="Say hello in exactly two words.", role="user")
    )
    print(response)


if __name__ == "__main__":
    asyncio.run(main())
```

`setup_agentscope()` initializes the Braintrust logger if one is not already active, then patches AgentScope.

## What Braintrust traces

Braintrust creates spans for:

* **Agent runs**: each agent invocation appears as a named task span
* **Sequential pipelines**: the pipeline run becomes a parent span, with child spans for each agent step
* **Tool execution**: tool calls appear as child tool spans under the active agent run
* **Underlying model calls**: LLM requests keep their normal model metadata, token metrics, and outputs

## Supported versions

The integration is tested against AgentScope `1.0.0` and the latest released version.

## Resources

* [Trace LLM calls](/instrument/trace-llm-calls)
* [AgentScope GitHub repository](https://github.com/modelscope/agentscope)
