diff --git a/internal/cmd/molecule_status.go b/internal/cmd/molecule_status.go index 7feb33d7..abf4500f 100644 --- a/internal/cmd/molecule_status.go +++ b/internal/cmd/molecule_status.go @@ -331,6 +331,11 @@ func runMoleculeStatus(cmd *cobra.Command, args []string) error { // not the agent from the GT_ROLE env var (which might be different if // we cd'd into another rig's crew/polecat directory) roleCtx = detectRole(cwd, townRoot) + if roleCtx.Role == RoleUnknown { + // Fall back to GT_ROLE when cwd doesn't identify an agent + // (e.g., at rig root like ~/gt/beads instead of ~/gt/beads/witness) + roleCtx, _ = GetRoleWithContext(cwd, townRoot) + } target = buildAgentIdentity(roleCtx) if target == "" { return fmt.Errorf("cannot determine agent identity (role: %s)", roleCtx.Role) @@ -760,6 +765,11 @@ func runMoleculeCurrent(cmd *cobra.Command, args []string) error { // not the agent from the GT_ROLE env var (which might be different if // we cd'd into another rig's crew/polecat directory) roleCtx = detectRole(cwd, townRoot) + if roleCtx.Role == RoleUnknown { + // Fall back to GT_ROLE when cwd doesn't identify an agent + // (e.g., at rig root like ~/gt/beads instead of ~/gt/beads/witness) + roleCtx, _ = GetRoleWithContext(cwd, townRoot) + } target = buildAgentIdentity(roleCtx) if target == "" { return fmt.Errorf("cannot determine agent identity (role: %s)", roleCtx.Role)