Files
Agent-System/internal/agent/backend.go
T
weichenandCursor 686f739b19 fix(pi-agent): enforce a no-tool reasoning profile
语义摘要、变更叙事和 U9 分段改为请求 reasoning。该 profile 的 argv 使用 --no-tools 且不加载搜索扩展;未知 profile 拒绝启动。文档生成仍保留读写工具。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-20 04:59:15 +00:00

56 lines
1.4 KiB
Go

package agent
import (
"context"
"time"
"chat-agent-system/internal/config"
)
type Request struct {
WorkDir string `json:"work_dir"`
Prompt string `json:"prompt"`
Instructions string `json:"instructions"`
Targets []string `json:"targets"`
Timeout time.Duration `json:"timeout"`
// ToolProfile is workspace (default, document tools) or reasoning (no tools).
ToolProfile string `json:"tool_profile,omitempty"`
}
const (
ToolProfileWorkspace = "workspace"
ToolProfileReasoning = "reasoning"
)
type Result struct {
Success bool `json:"success"`
Patches map[string][]byte `json:"patches"`
Logs string `json:"logs"`
ErrorReason string `json:"error_reason"`
// Retryable marks a provider-transient failure that may receive a
// fresh step invocation. Permanent missing deliverables stay false.
Retryable bool `json:"retryable,omitempty"`
}
type Backend interface {
Name() string
Execute(ctx context.Context, req Request) (*Result, error)
}
func NewBackend(name string, cfg *config.Config) Backend {
var inner Backend
switch name {
case "pi-agent":
inner = &PiAgentBackend{cfg: cfg}
case "cursor-cli":
inner = &CursorCLIBackend{cfg: cfg}
default:
inner = &StubBackend{}
}
max := 8
if cfg != nil && cfg.MaxConcurrentAgents > 0 {
max = cfg.MaxConcurrentAgents
}
return WrapWithConcurrencyLimit(inner, max)
}