2e2bd441c6
* fix(passthrough): apply profile cli_flags to passthrough command PassthroughOptions had no CLIFlagTokens field, so the passthrough launch path silently dropped profile-configured cli_flags. Mirror the ACP launch path: resolve via cliflags.Resolve and append the tokens through StandardPassthrough.BuildPassthroughCommand. Fixes #718. * fix(passthrough): skip auto-restart on fast-fail launch errors A bad CLI flag, missing binary, or auth failure makes the agent process exit immediately. The auto-restart loop then thrashed forever, spamming "[Agent exited. Restarting...]" without ever recovering. Track the start time of each passthrough process and short-circuit the restart path when an exit lands within 2s with a non-zero code. Surface a one-shot terminal banner pointing the user at the likely fix instead. * refactor(passthrough): snapshot start time at call site to avoid race Claude review on PR #722: handlePassthroughExit ran in a goroutine and read execution.PassthroughStartedAt while the next launch could concurrently write it. Snapshot the value synchronously in handlePassthroughStatus and thread it through; isFastFailExit now takes the start time directly. Also extracts attemptPassthroughRestart and notifyFastFailExit to keep handlePassthroughExit under the funlen limit. * refactor(passthrough): measure fast-fail uptime from status timestamp Claude review on PR #722: handlePassthroughExit's uptime measurement folded in the cleanupDelay sleep (~100 ms), so the logged duration was systematically inflated and a process that died at, say, 1.95 s would slip past the 2 s cutoff. Use status.Timestamp (set when the child actually exited) as the exit time and pass it through to isFastFailExit. notifyFastFailExit now receives a pre-computed uptime so the log reflects real child runtime.
33 lines
1.0 KiB
Go
33 lines
1.0 KiB
Go
package agents
|
|
|
|
// StandardPassthrough provides a data-driven implementation of PassthroughAgent.
|
|
// Agents embed this struct and configure it declaratively to get passthrough support.
|
|
type StandardPassthrough struct {
|
|
Cfg PassthroughConfig
|
|
PermSettings map[string]PermissionSetting
|
|
}
|
|
|
|
// PassthroughConfig returns the passthrough configuration.
|
|
func (p *StandardPassthrough) PassthroughConfig() PassthroughConfig {
|
|
return p.Cfg
|
|
}
|
|
|
|
// BuildPassthroughCommand builds a CLI command for passthrough mode.
|
|
func (p *StandardPassthrough) BuildPassthroughCommand(opts PassthroughOptions) Command {
|
|
b := p.Cfg.PassthroughCmd.With().
|
|
Model(p.Cfg.ModelFlag, opts.Model).
|
|
Settings(p.PermSettings, opts.PermissionValues).
|
|
Flag(opts.CLIFlagTokens...)
|
|
|
|
switch {
|
|
case opts.SessionID != "" && !p.Cfg.SessionResumeFlag.IsEmpty():
|
|
b.Resume(p.Cfg.SessionResumeFlag, opts.SessionID, false)
|
|
case opts.Resume && !p.Cfg.ResumeFlag.IsEmpty():
|
|
b.Flag(p.Cfg.ResumeFlag.Args()...)
|
|
case opts.Prompt != "":
|
|
b.Prompt(p.Cfg.PromptFlag, opts.Prompt)
|
|
}
|
|
|
|
return b.Build()
|
|
}
|