fix(dog): export env vars in startup command and add dog identity detection
Some checks failed
CI / Check for .beads changes (push) Has been skipped
CI / Check embedded formulas (push) Successful in 26s
CI / Test (push) Failing after 1m40s
CI / Lint (push) Successful in 25s
CI / Integration Tests (push) Successful in 1m30s
CI / Coverage Report (push) Has been skipped
Windows CI / Windows Build and Unit Tests (push) Has been cancelled
Some checks failed
CI / Check for .beads changes (push) Has been skipped
CI / Check embedded formulas (push) Successful in 26s
CI / Test (push) Failing after 1m40s
CI / Lint (push) Successful in 25s
CI / Integration Tests (push) Successful in 1m30s
CI / Coverage Report (push) Has been skipped
Windows CI / Windows Build and Unit Tests (push) Has been cancelled
The previous fix only added the "dog" case to AgentEnv but dogs still couldn't find their mail because: 1. BuildAgentStartupCommand doesn't pass AgentName, so BD_ACTOR was empty 2. detectSenderFromRole had no "dog" case, falling back to "overseer" Fixes: - Add BuildDogStartupCommand that properly passes dog name to AgentEnv - Update dog dispatch to use BuildDogStartupCommand - Add "dog" case to detectSenderFromRole that reads BD_ACTOR The env vars are now exported in the startup command (via exec env) so the agent inherits them when it starts, rather than relying on tmux setenv which only affects new shells. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -808,7 +808,7 @@ func runDogDispatch(cmd *cobra.Command, args []string) error {
|
||||
|
||||
// Build startup command with initial prompt to check mail and execute plugin
|
||||
initialPrompt := fmt.Sprintf("I am dog %s. Check my mail inbox with 'gt mail inbox' and execute the plugin instructions I received.", targetDog.Name)
|
||||
startCmd := config.BuildAgentStartupCommand("dog", "", townRoot, targetDog.Path, initialPrompt)
|
||||
startCmd := config.BuildDogStartupCommand(targetDog.Name, targetDog.Path, townRoot, initialPrompt)
|
||||
|
||||
// Create session from dog's directory
|
||||
if err := t.NewSessionWithCommand(dogSessionName, targetDog.Path, startCmd); err != nil {
|
||||
@@ -818,7 +818,9 @@ func runDogDispatch(cmd *cobra.Command, args []string) error {
|
||||
// Non-fatal: mail was sent, dog is marked as working, but no session to execute
|
||||
// The deacon or human can manually start the session later
|
||||
} else {
|
||||
// Set environment for the dog session
|
||||
// Also set tmux environment as a fallback (belt and suspenders).
|
||||
// The startup command exports these vars, but setting them in tmux
|
||||
// environment ensures new panes/windows in the session inherit them.
|
||||
envVars := config.AgentEnv(config.AgentEnvConfig{
|
||||
Role: "dog",
|
||||
AgentName: targetDog.Name,
|
||||
|
||||
@@ -129,6 +129,14 @@ func detectSenderFromRole(role string) string {
|
||||
return fmt.Sprintf("%s/refinery", rig)
|
||||
}
|
||||
return detectSenderFromCwd()
|
||||
case "dog":
|
||||
// Dogs use BD_ACTOR directly since they're town-level (no rig)
|
||||
// Format: deacon/dogs/<name>
|
||||
actor := os.Getenv("BD_ACTOR")
|
||||
if actor != "" {
|
||||
return actor
|
||||
}
|
||||
return detectSenderFromCwd()
|
||||
default:
|
||||
// Unknown role, try cwd detection
|
||||
return detectSenderFromCwd()
|
||||
|
||||
@@ -1472,6 +1472,18 @@ func BuildCrewStartupCommandWithAgentOverride(rigName, crewName, rigPath, prompt
|
||||
return BuildStartupCommandWithAgentOverride(envVars, rigPath, prompt, agentOverride)
|
||||
}
|
||||
|
||||
// BuildDogStartupCommand builds the startup command for a deacon dog.
|
||||
// Dogs are town-level agents, so they don't have a rig.
|
||||
// Sets GT_ROLE=dog, BD_ACTOR=deacon/dogs/<name>, and GT_ROOT.
|
||||
func BuildDogStartupCommand(dogName, dogPath, townRoot, prompt string) string {
|
||||
envVars := AgentEnv(AgentEnvConfig{
|
||||
Role: "dog",
|
||||
AgentName: dogName,
|
||||
TownRoot: townRoot,
|
||||
})
|
||||
return BuildStartupCommand(envVars, dogPath, prompt)
|
||||
}
|
||||
|
||||
// ExpectedPaneCommands returns tmux pane command names that indicate the runtime is running.
|
||||
// Claude can report as "node" (older versions) or "claude" (newer versions).
|
||||
// Other runtimes typically report their executable name.
|
||||
|
||||
Reference in New Issue
Block a user