Files
runny 9058149576
Build & Publish (dsh-academy) / End-to-end inside dsh (latest, advisory) (push) Skipped
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Frontend / Docker multi-stage image (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-academy) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-academy) / Publish to npm (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Helm / chart (push) Canceled after 0s
refactor: 项目更名 WeKnora → Academy
- 全量替换代码/配置/文档中的项目名(保留上游 GitHub 链接、weixin 文档域名、Docker Hub 镜像名)
- 重命名 32 个含项目名的文件/目录;Go module 路径改为 academy(含 client/cli 子模块)
- docreader proto 描述符采用等长替换,保持序列化字节布局有效
- Dockerfile.app 构建网络修复: browserskill 离线产物通道、PyPI/apt 国内镜像
- 运行验证: go build ✓ docker compose up ✓ 健康检查 ✓
2026-11-13 20:52:51 +08:00

65 lines
2.7 KiB
Go

package agent
import (
"testing"
"time"
"academy/internal/types"
"github.com/stretchr/testify/assert"
)
// A provider rejects a request for more output than the model can emit, so the
// round budget and the history reserve both follow the model's limit.
func TestCompletionBudgetFollowsModelOutputLimit(t *testing.T) {
cfg := &types.AgentConfig{}
assert.Equal(t, types.DefaultSmartReasoningMaxCompletionTokens, completionTokenBudgetFor(cfg))
cfg.ModelMaxOutputTokens = 8192
assert.Equal(t, 8192, completionTokenBudgetFor(cfg))
assert.Less(t, reserveTokensFor(cfg), types.DefaultSmartReasoningMaxCompletionTokens)
cfg.MaxCompletionTokens = 4096
assert.Equal(t, 4096, completionTokenBudgetFor(cfg), "a smaller configured budget is kept")
cfg.MaxCompletionTokens = 32000
assert.Equal(t, 8192, completionTokenBudgetFor(cfg), "an explicit budget cannot exceed the model")
}
func TestToolExecutionTimeout(t *testing.T) {
// shell_exec and browser human steps keep their longer budgets.
assert.Equal(t, 10*time.Minute+5*time.Second, toolExecutionTimeout("shell_exec"))
for _, method := range []string{"request_help", "tab_borrow"} {
assert.Equal(t, 5*time.Minute+15*time.Second,
toolExecutionTimeout("local_browser", `{"method":"`+method+`"}`))
}
// knowledge_search and non-human browser calls stay at 60s.
assert.Equal(t, 60*time.Second, toolExecutionTimeout("knowledge_search"))
for _, args := range []string{`{"method":"click"}`, `{"method":"observe"}`, `{`} {
assert.Equal(t, 60*time.Second, toolExecutionTimeout("local_browser", args))
}
t.Run("default budget plus slack", func(t *testing.T) {
t.Setenv("ACADEMY_WEB_FETCH_TIMEOUT", "")
assert.Equal(t, 35*time.Second, toolExecutionTimeout("web_fetch"))
})
t.Run("go duration", func(t *testing.T) {
t.Setenv("ACADEMY_WEB_FETCH_TIMEOUT", "150s")
assert.Greater(t, toolExecutionTimeout("web_fetch"), 2*time.Minute+30*time.Second)
assert.Equal(t, 2*time.Minute+35*time.Second, toolExecutionTimeout("web_fetch"))
})
t.Run("bare seconds", func(t *testing.T) {
t.Setenv("ACADEMY_WEB_FETCH_TIMEOUT", "180")
assert.Equal(t, 185*time.Second, toolExecutionTimeout("web_fetch"))
})
t.Run("invalid falls back", func(t *testing.T) {
t.Setenv("ACADEMY_WEB_FETCH_TIMEOUT", "nope")
assert.Equal(t, 35*time.Second, toolExecutionTimeout("web_fetch"))
})
}
func TestWorkWaitToolTimeoutCoversTheWait(t *testing.T) {
assert.Equal(t, 90*time.Second, toolExecutionTimeout("work_wait", `{"work_ids":["a"]}`))
assert.Equal(t, 30*time.Second, toolExecutionTimeout("work_wait", `{"wait_sec":0}`))
assert.Equal(t, 330*time.Second, toolExecutionTimeout("work_wait", `{"wait_sec":999}`))
assert.Equal(t, 90*time.Second, toolExecutionTimeout("work_wait"))
}