fix(dog): properly set identity for dog sessions
Some checks failed
CI / Check for .beads changes (push) Has been skipped
CI / Check embedded formulas (push) Successful in 25s
CI / Test (push) Failing after 1m22s
CI / Lint (push) Failing after 16s
CI / Integration Tests (push) Successful in 1m9s
CI / Coverage Report (push) Has been skipped
Windows CI / Windows Build and Unit Tests (push) Has been cancelled

Three fixes to make dog dispatch work end-to-end:

1. Add BuildDogStartupCommand in loader.go
   - Similar to BuildPolecatStartupCommand/BuildCrewStartupCommand
   - Passes AgentName to AgentEnv so BD_ACTOR is exported in startup command

2. Use BuildDogStartupCommand in dog.go
   - Removes ineffective SetEnvironment calls (env vars set after shell starts
     don't propagate to already-running processes)

3. Add "dog" case in mail_identity.go detectSenderFromRole
   - Dogs now use BD_ACTOR for mail identity
   - Without this, dogs fell through to "overseer" and couldn't find their mail

Tested: dog alpha now correctly sees inbox as deacon/dogs/alpha

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
riker
2026-01-22 11:44:45 -08:00
committed by John Ogle
parent f0014bb21a
commit 6be7fdd76c
3 changed files with 20 additions and 11 deletions

View File

@@ -852,8 +852,9 @@ func runDogDispatch(cmd *cobra.Command, args []string) error {
}
// Build startup command with initial prompt to check mail and execute plugin
// Use BuildDogStartupCommand to properly set BD_ACTOR=deacon/dogs/<name> in the startup command
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, townRoot, targetDog.Path, initialPrompt)
// Create session from dog's directory
if err := t.NewSessionWithCommand(dogSessionName, targetDog.Path, startCmd); err != nil {
@@ -862,16 +863,6 @@ 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
envVars := config.AgentEnv(config.AgentEnvConfig{
Role: "dog",
AgentName: targetDog.Name,
TownRoot: townRoot,
})
for k, v := range envVars {
_ = t.SetEnvironment(dogSessionName, k, v)
}
}
// Success - output result

View File

@@ -129,6 +129,13 @@ func detectSenderFromRole(role string) string {
return fmt.Sprintf("%s/refinery", rig)
}
return detectSenderFromCwd()
case "dog":
// Dogs use BD_ACTOR directly (set by BuildDogStartupCommand)
actor := os.Getenv("BD_ACTOR")
if actor != "" {
return actor
}
return detectSenderFromCwd()
default:
// Unknown role, try cwd detection
return detectSenderFromCwd()

View File

@@ -1457,6 +1457,17 @@ func BuildPolecatStartupCommandWithAgentOverride(rigName, polecatName, rigPath,
return BuildStartupCommandWithAgentOverride(envVars, rigPath, prompt, agentOverride)
}
// BuildDogStartupCommand builds the startup command for a deacon dog.
// Sets GT_ROLE, BD_ACTOR, GIT_AUTHOR_NAME, and GT_ROOT.
func BuildDogStartupCommand(dogName, townRoot, dogPath, prompt string) string {
envVars := AgentEnv(AgentEnvConfig{
Role: "dog",
AgentName: dogName,
TownRoot: townRoot,
})
return BuildStartupCommand(envVars, dogPath, prompt)
}
// BuildCrewStartupCommand builds the startup command for a crew member.
// Sets GT_ROLE, GT_RIG, GT_CREW, BD_ACTOR, GIT_AUTHOR_NAME, and GT_ROOT.
func BuildCrewStartupCommand(rigName, crewName, rigPath, prompt string) string {