agentscope-ai / agentscope-ai/agentscope

[Bug]:set_console_output_enabled(False) unexpectedly disables AgentScope Studio tracing/output

オープン
#1,149 コメント 1 件 リアクション 0 件 担当者 1 名 @zhijianma が担当を希望しています GitHub で見る
Bug state: in progress
主要言語
Python
スター
31.6k
フォーク
3.5k
平均マージ
1日 16時間
マージ済み PR(30日)
103

説明

### Description

In recent versions of AgentScope (main branch), calling:

```python
agent.set_console_output_enabled(enabled=False)
```

does not only disable console output, but also **silently disables message forwarding to AgentScope Studio**, including message display and tracing.

This behavior is **not documented** and is **inconsistent with the method name and its docstring**, which only mention disabling console output in production environments.

------

### Expected Behavior

- `set_console_output_enabled(False)` should **only affect console printing**
- AgentScope Studio should continue to receive:
- messages
- metadata
- traces / spans

This was the behavior in earlier versions, where console output and Studio tracing were independent.

------

### Actual Behavior

When `set_console_output_enabled(False)` is set:

- Console output is disabled ✅
- **Studio message display and tracing are also disabled ❌**
- No warning or documentation indicates this global side effect

Root cause (from source code):

In
`src/agentscope/hooks/_studio_hooks.py`

```python
if self._disable_console_output:
return
```

Studio hooks directly depend on the console output flag, effectively treating Studio as a “visual console” rather than an independent output channel.

------

### Why This Is a Problem

1. **Semantic mismatch**

- Method name and docstring only reference console output:

> “in a production environment, you may want to disable the console output to avoid messy logs”

- There is no mention that this disables Studio / tracing.

2. **Breaks production workflows**

- A common use case is:
- disable console logs in production
- keep Studio / tracing enabled for observability
- This is currently impossible without modifying source code.

3. **Backward incompatibility**

- Previous AgentScope versions allowed disabling console output while keeping tracing intact.
- The behavior change is undocumented.

------

### Suggested Improvements

One of the following would resolve the issue:

1. **Decouple Studio output from console output**

- Introduce a separate flag, e.g.:

```
set_studio_output_enabled(True | False)
```

2. **At minimum, update documentation**

- Clearly state that `set_console_output_enabled(False)`:
- disables console output
- disables Studio message display
- disables tracing

3. **Emit a warning**

- When disabling console output while Studio is enabled, warn users about the side effect.

------

### Temporary Workaround

Manually comment out or modify the following line:

https://github.com/agentscope-ai/agentscope/blob/main/src/agentscope/hooks/_studio_hooks.py#L19

```
if self._disable_console_output:
return
```

This restores the expected behavior:
**console disabled, Studio still active**.

------

### Environment

- AgentScope version: `main` (current)
- Python: 3.13.7
- AgentScope Studio: latest available
- OS: Windows / Linux

------

### Closing

This appears to be an architectural change made for consistency, but without sufficient documentation or API-level clarity.
Clarifying or decoupling these behaviors would significantly improve usability in production and observability-focused setups.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。