fix(dog): properly set identity for dog sessions

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 2590e3de3b
commit c3fb9c6027
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()