fix(handoff): preserve GT_AGENT across session restarts (#788)
Adds GT_AGENT env var to track agent override when using --agent flag. Handoff reads and preserves GT_AGENT so non-default agents persist across restarts. Co-authored-by: joshuavial <git@codewithjv.com>
This commit is contained in:
@@ -384,7 +384,20 @@ func buildRestartCommand(sessionName string) (string, error) {
|
||||
// 3. export Claude-related env vars (not inherited by fresh shell)
|
||||
// 4. run claude with the startup beacon (triggers immediate context loading)
|
||||
// Use exec to ensure clean process replacement.
|
||||
runtimeCmd := config.GetRuntimeCommandWithPrompt("", beacon)
|
||||
//
|
||||
// Check if current session is using a non-default agent (GT_AGENT env var).
|
||||
// If so, preserve it across handoff by using the override variant.
|
||||
currentAgent := os.Getenv("GT_AGENT")
|
||||
var runtimeCmd string
|
||||
if currentAgent != "" {
|
||||
var err error
|
||||
runtimeCmd, err = config.GetRuntimeCommandWithPromptAndAgentOverride("", beacon, currentAgent)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("resolving agent config: %w", err)
|
||||
}
|
||||
} else {
|
||||
runtimeCmd = config.GetRuntimeCommandWithPrompt("", beacon)
|
||||
}
|
||||
|
||||
// Build environment exports - role vars first, then Claude vars
|
||||
var exports []string
|
||||
@@ -398,6 +411,11 @@ func buildRestartCommand(sessionName string) (string, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Preserve GT_AGENT across handoff so agent override persists
|
||||
if currentAgent != "" {
|
||||
exports = append(exports, "GT_AGENT="+currentAgent)
|
||||
}
|
||||
|
||||
// Add Claude-related env vars from current environment
|
||||
for _, name := range claudeEnvVars {
|
||||
if val := os.Getenv(name); val != "" {
|
||||
|
||||
Reference in New Issue
Block a user