Files
Agent-System/internal/agent/backend.go
T
weichenandCursor 98619c7b56 feat(agent): classify settled-failure as bounded retryable
Treat process-0 plus terminated/Connection error/auto_retry_end as a
provider transient. Permanent missing deliverables stay fail-closed and
are never reconstructed from truncated write arguments.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-13 19:16:46 +00:00

49 lines
1.2 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"`
}
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)
}