enable token usage by default (#2841)

This commit is contained in:
YuJitang 2026-05-10 22:00:57 +08:00 committed by GitHub
parent dfa4eb0c1a
commit 5127f08e1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 21 additions and 6 deletions

View File

@ -4,4 +4,4 @@ from pydantic import BaseModel, Field
class TokenUsageConfig(BaseModel):
"""Configuration for token usage tracking."""
enabled: bool = Field(default=False, description="Enable token usage tracking middleware")
enabled: bool = Field(default=True, description="Enable token usage tracking middleware")

View File

@ -313,7 +313,7 @@ class TestWriteConfigYaml:
{
"config_version": 5,
"log_level": "info",
"token_usage": {"enabled": False},
"token_usage": {"enabled": True},
"tool_groups": [{"name": "web"}, {"name": "file:read"}, {"name": "file:write"}, {"name": "bash"}],
"tools": [
{
@ -361,7 +361,7 @@ class TestWriteConfigYaml:
data = yaml.safe_load(f)
assert data["log_level"] == "info"
assert data["token_usage"]["enabled"] is False
assert data["token_usage"]["enabled"] is True
assert data["tool_groups"][0]["name"] == "web"
assert data["summarization"]["max_tokens"] == 2048
assert any(tool["name"] == "image_search" and tool["max_results"] == 5 for tool in data["tools"])

View File

@ -0,0 +1,5 @@
from deerflow.config.token_usage_config import TokenUsageConfig
def test_token_usage_enabled_by_default():
assert TokenUsageConfig().enabled is True

View File

@ -30,7 +30,7 @@ log_level: info
# When enabled, DeerFlow records input/output/total tokens per model call
# and shows usage metadata in the workspace UI when providers return it.
token_usage:
enabled: false
enabled: true
# ============================================================================
# Models Configuration

View File

@ -110,7 +110,7 @@ Tracks LLM token consumption per model call and logs it at the `info` level. Use
```yaml
token_usage:
enabled: false
enabled: true
```
---

View File

@ -110,7 +110,7 @@ title:
```yaml
token_usage:
enabled: false
enabled: true
```
---

View File

@ -0,0 +1,10 @@
import { expect, test } from "vitest";
import { DEFAULT_LOCAL_SETTINGS } from "@/core/settings/local";
test("defaults token usage to header total plus per-turn breakdown", () => {
expect(DEFAULT_LOCAL_SETTINGS.tokenUsage).toEqual({
headerTotal: true,
inlineMode: "per_turn",
});
});