Skip to content

feat(tools): optimize tool system pipeline#181

Closed
520wheat wants to merge 6 commits into1024XEngineer:mainfrom
520wheat:feat/tool-system-pr1
Closed

feat(tools): optimize tool system pipeline#181
520wheat wants to merge 6 commits into1024XEngineer:mainfrom
520wheat:feat/tool-system-pr1

Conversation

@520wheat
Copy link
Copy Markdown
Collaborator

摘要

  • 将工具执行链路从 Runner -> Registry -> Tool.Run 升级为
    Runner -> Executor -> decode/permission/execute/normalize -> Tool.Run
  • 在 registry 中引入 spec 维度,统一工具暴露信息与运行时语义来源
  • 拆分并整理 agent/app/runtime/context/policy/storage 相关模块,降低耦合并提升可测试性

原因

  • 解决原链路中“暴露定义”和“执行语义”分散导致的漂移问题
  • 为后续权限治理、并发调度、工具稳定性治理提供统一入口
  • 降低 Runner 复杂度,明确 decode/permission/execute/normalize 的职责边界

测试

  • 本地完成相关单测与回归验证
  • 分支已 rebase 到 upstream/refactor
  • 当前分支:feat/tool-system-pr1

Copy link
Copy Markdown

@xgopilot xgopilot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified findings from this review:

  1. High – build regression (duplicate symbols)
    internal/tui/model.go:2125 (also 2316, 2330, 2428, 2452, 2456, 2464, 3301, 3333, 3381)

go test currently fails because functions in model.go are redeclared while also existing in extracted component files (component_conversation.go, component_footer.go, component_status_scroll.go).

  1. High – test compile regression
    internal/agent/runner_test.go / internal/agent/runner_complex_test.go:89 (also 193, 252, 348, 393)

runner_complex_test.go still references generousTokenQuota, but that symbol is no longer defined after this refactor. go test ./internal/agent fails with undefined: generousTokenQuota.

  1. High – path traversal risk
    internal/storage/session_files.go:75

SessionPath() joins raw sessionID directly into a filesystem path without validating separators or traversal (..). This allows path escape if a crafted session id is loaded/saved.

  1. Medium – sensitive data exposure risk
    internal/storage/prompt_history.go:106, internal/storage/audit.go:85, internal/agent/tool_execution.go:89-92

Raw prompts and tool error strings are persisted, and files are created with mode 0644. This can leak sensitive content on multi-user systems; prefer stricter permissions (for example 0600) and avoid persisting full error payloads by default.

  1. Medium – unrelated artifact committed
    generate_random.go:1, generate_random.py:1

These files appear unrelated to the tool-system/app refactor and include hardcoded personal desktop paths. They should be removed from this PR.

Validation performed:

  • go test ./internal/app ./internal/agent ./internal/tools ./internal/tui (fails with the compile issues above).

rand.Seed(time.Now().UnixNano())

// 桌面路径
desktopPath := "C:\\Users\\wheat\\Desktop\\随机数.txt"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file appears unrelated to the PR scope (tool pipeline/app refactor) and contains a hardcoded personal desktop path. Please remove this artifact (and its Python counterpart) from the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants